centos 7安装 mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

前言:
因为源码包安装mysql太费劲,经常报各种错,不是gcc+版本 过低就是cmake版本过低,安装好依赖包后还报版本不匹配,真对这些问题我决定放弃源码包安装转战rpm包

将下载好的mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar包上传至临时安装目录/mnt下

cd /mnt
ls
```javascript
   tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

解压后的rpm包按顺序安装一下四个rpm包

  rpm -ivh mysql-community-common-8.0.19-1.el7.x86_64.rpm --nodeps --force
  rpm -ivh mysql-community-libs-8.0.19-1.el7.x86_64.rpm --nodeps --force  
  rpm -ivh mysql-community-client-8.0.19-1.el7.x86_64.rpm  --nodeps --force
   rpm -ivh mysql-community-server-8.0.19-1.el7.x86_64.rpm --nodeps --force   
  rpm -qa | grep mysql 

对mysql进行初始化

  mysqld --initialize;

如果在初始化时报一下错误,是因为缺少了numactl软件包

 bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

真对报错缺少的numactl软件包进行安装

yum -y install numactl

以上操作后mysqld --initialize;任报错请将 /var/lib/mysql删除

rm -rf /var/lib/mysql

继续执行一下操作

  chown mysql:mysql /var/lib/mysql -R;
  systemctl start mysqld.service;
  systemctl enable mysqld;
  cat /var/log/mysqld.log | grep password
  mysql -uroot -p
   systemctl stop firewalld.service;
   systemctl disable firewalld.service;
   systemctl mask firewalld.service;
   ifconfig

通过 cat /var/log/mysqld.log | grep password 命令查看数据库的密码
在这里插入图片描述
通过 mysql -uroot -p 敲回车键进入数据库登陆界面

通过 ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’; 命令来修改密码

通过 exit; 命令退出 MySQL,然后通过新密码再次登陆

.通过以下命令,进行远程访问的授权
create user ‘root’@’%’ identified with mysql_native_password by ‘root’;
grant all privileges on . to ‘root’@’%’ with grant option;
flush privileges;

通过 ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘root’ PASSWORD EXPIRE NEVER; 命令修改加密规则,MySql8.0 版本 和 5.0 的加密规则不一样,而现在的可视化工具只支持旧的加密方式。

通过 flush privileges; 命令刷新修该后的权限

通过以下命令,关闭 firewall(防火墙)

systemctl stop firewalld.service;
systemctl disable firewalld.service;
systemctl mask firewalld.service;

你可能感兴趣的:(Linux服务器,MYSQL)