1. 下载MySQL源安装包
> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2. 安装MySQL源
> yum localinstall mysql57-community-release-el7-8.noarch.rpm
3. 检查MySQL源是否安装成功
> yum repolist enabled | grep "mysql.*-community.*"
4. 安装MySQL
> yum install mysql-community-server
5. 启动MySQL服务
> systemctl start mysqld
6. 设置MySQL开机启动
> systemctl enable mysqld
> systemctl daemon-reload
7. 查看MySQLroot用户的默认密码
> grep 'temporary password' /var/log/mysqld.log
8. 连接MySQL,修改root用户默认密码
> mysql -uroot -p9L2dgbYNtZ.d
> alter user 'root'@'localhost' identified by '#{new password}'
必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位
9. 添加远程登陆用户
> grant all privileges on *.* to 'root'@'%' identified by '#{new password}' with grant option;
10. 关闭防火墙(可选)
-- 查看防火墙情况
> systemctl status firewalld.service
-- 关闭防火墙
> systemctl stop firewalld.service
-- 设置防火墙开机不启动
> systemctl disable firewalld.service