1. 安装rpm包
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server
2. 启动
sudo systemctl start mysqld
检查启动是否成功
sudo systemctl status mysqld
4. 连接
找到临时密码
sudo grep 'temporary password' /var/log/mysqld.log
输出如下
2016-12-01T00:22:31.416107Z 1 [Note] A temporary password is generated for root@localhost: mqRfBU_3Xk>r
使用该密码连接。
5. 修改root密码 & 检查自启动
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
重启机器,检查MySQL是否还在。