安装yum源
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
安装 mysql-community-server
yum -y install mysql-community-server
可能会报错
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
解决
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
mysql -u root -p 需要密码
mysql -u root 报错 怎么解决
修改MySQL的登录设置:
vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存并且退出vi。
systemctl restart mysqld
vim /etc/my.cnf
skip-grant-tables
wq!
systemctl restart mysqld
mysql -u root -p
直接回车,跳过密码登录成功
#刷新权限
flush privileges;
#修改密码
set password for root@localhost='1';
exit
vim /etc/my.cnf
#skip-grant-tables
wq!
systemctl restart mysqld
mysql -u root -p
输入密码登录成功