安装包准备
下载mysql8 rpm包,地址:https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
安装
执行命令,安装以下rpm
yum install -y mysql-community-client-8.0.33-1.el7.x86_64.rpm \
mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm \
mysql-community-common-8.0.33-1.el7.x86_64.rpm \
mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm \
mysql-community-libs-8.0.33-1.el7.x86_64.rpm \
mysql-community-libs-compat-8.0.33-1.el7.x86_64.rpm \
mysql-community-server-8.0.33-1.el7.x86_64.rpm
配置
编辑 /etc/my.cnf
添加 default-authentication-plugin=mysql_native_password
[mysqld]
default-authentication-plugin=mysql_native_password
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
修改密码
重启mysql
systemctl restart mysqld
获取临时密码
cat /var/log/mysqld.log | grep -i password
登录mysql,修改root密码
mysql -u root -p
ALTER USER USER() IDENTIFIED BY 'C@p19U#qfo';