第一步 卸载centos自带的mariadb
使用以下进行命令查看
rpm -qa|grep mariadb
如有下面的信息说明CentOS自带mariadb,没安装跳过这一步:
卸载mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
第二步 下载MySQL 8.0.13
新建文件夹用于存放MySQL 8.0.13
mkdir xxx
使用wget命令下载MySQL 8.0.13放在刚创建的文件夹内
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
第三步 安装MySQL 8.0.13
解压MySQL 8.0.13
tar -xvf mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar
出现以下信息说明解压成功
mysql-community-client-8.0.13-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm
mysql-community-libs-8.0.13-1.el7.x86_64.rpm
mysql-community-server-8.0.13-1.el7.x86_64.rpm
mysql-community-common-8.0.13-1.el7.x86_64.rpm
mysql-community-devel-8.0.13-1.el7.x86_64.rpm
mysql-community-test-8.0.13-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm
安装libaio
yum install -y libaio
按照以下顺序安装这些rpm包
#安装 mysql-community-common-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
#安装ysql-community-libs-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm
#安装mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.13-1.el7.x86_64.rpm
#安装mysql-community-client-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm
#安装mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.13-1.el7.x86_64.rpm
#安装mysql-community-server-8.0.13-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
第四步 启动MySQL 8.0.13
service mysqld start
第五步 配置MySQL 8.0.13
查看临时密码
grep 'temporary password' /var/log/mysqld.log
使用刚才的密码进入MySQL 8.0.13
mysql -u root -p
修改临时密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '!Password1';
刷新权限
flush privileges;
查看初试密码策略
SHOW VARIABLES LIKE 'validate_password%';
修改密码策略为最低
set global validate_password.policy=LOW;
修改密码长度为6
set global validate_password.length=6;
再次修改密码为最简单并刷新权限
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
flush privileges;
第五步 使用Navicat等工具连接MySQL 8.0.13
若出现以下情况,是因为8.0的密码加密方式从mysql_native_password变成了caching_sha2_password,只需要修改一下加密方式即可:
更改加密方式
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
再次连接就好了