下载并安装MySQL官方的 Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum安装mysql-server
yum -y install mysql-community-server
启动mysql服务
systemctl start mysqld.service
查看安装mysql时自动生成的初始密码
grep "password" /var/log/mysqld.log
进入mysql
mysql -uroot -p
设置新密码
mysql> ALTER USER USER() IDENTIFIED BY '新的密码';
允许所有来源的访问(生产环境危险)
mysql> update user set host = '%' where user = 'root';
刷新使修改生效。
mysql> flush privileges;
执行exit退出mysql,开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload