- 获取MySQL5.7yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
- 安装MySQL
yum install -y mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql-community-server
- 启动MySQL
systemctl start mysqld
- 查看MySQL初始密码
cat /var/log/mysqld.log | grep "password"
- 登录MySQL,执行下面的命令后输入第4步查出来的密码
mysql -u root -p
- 修改root密码
set global validate_password_policy=0;
set password for root@localhost = password('new password');
flush privileges;
- 开放本地连接MySQL
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
【参考链接】
https://www.cnblogs.com/wangbg/p/15930531.html
https://blog.csdn.net/weixin_47593552/article/details/111604643/