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.检查源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4.安装mysql
这一步才是真正安装mysql
yum install mysql-community-server
5.启动mysql服务并设置开机启动
systemctl start mysqld
systemctl enable mysqld
systemctl daemon-reload
6.开放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
7.修改root本地登录密码
7.1 查看mysql密码
grep 'temporary password' /var/log/mysqld.log
7.2 连接mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
8.添加远程登录用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myUser'@'%' IDENTIFIED BY 'myPassword' WITH GRANT OPTION;