使用 yum 進(jìn)行安裝
添加 mysql yum 源
shell> cd /tmp && wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# 本地安裝源
shell> yum localinstall -y mysql80-community-release-el7-3.noarch.rpm
# 查看源啟動(dòng)情況
shell> yum repolist all | grep mysql
image.png
切換到 5.7
# 禁用 mysql 8.0
shell> sudo yum-config-manager --disable mysql80-community
# 啟用 mysql 5.7
shell> sudo yum-config-manager --enable mysql57-community
# 安裝 mysql 5.7
shell> sudo yum install -y mysql-community-server
設(shè)置開(kāi)機(jī)啟動(dòng)并啟動(dòng)服務(wù)
shell> systemctl enable mysqld
shell> systemctl start mysqld
shell> systemctl status mysqld
查看默認(rèn)密碼
shell> sudo grep 'temporary password' /var/log/mysqld.log
修改 root 密碼
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
