1.查看是否安装Mysql
rpm -qa | grep mysql
查出来没有显示任何内容,说明没有安装Mysql
查出来有内容直接使用 rpm -e 文件名 删除
2.下载官方Mysql包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
3.安装Mysql数据包
yum -y install mysql57-community-release-el7-10.noarch.rpm
4.安装Mysql
yum -y install mysql-community-server
5.启动Mysql
systemctl start mysqld.service
6.查看初始密码
grep 'password' /var/log/mysqld.log
7.进入数据库
mysql -u root -p
8.重置密码
ALTER USER USER() IDENTIFIED BY 'wingkin45';#wingkin为密码
第四步报错:
Public key for mysql-community-server-5.7.37-1.el7.x86_64.rpm is not installed
解决方法:Mysql的GPG升级了,需要重新获取
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022