1.下载yum 源
wgethttps://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
# 链接在这里找https://dev.mysql.com/downloads/repo/yum/
2.安装 yum 源
sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
3.显示所有的 GA 版本
yum repolist all | grep mysql
4.选择安装的版本
sudo yum-config-manager --disable mysql57-community
sudo yum-config-manager --enable mysql56-community
如果遇到sudo:yum-config-manager:找不到命令
yum -y install yum-utils
yum repolist enabled | grep mysql
5.安装
sudo yum install mysql-community-server
6.启动 Mysql Server
sudo service mysqld start
sudo systemctl start mysqld.service
sudo service mysqld status
sudo systemctl status mysqld.service
7.MySQL Server Initialization (for MySQL 5.7 only):
A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
sudo grep 'temporary password' /var/log/mysqld.log
其他版本没有密码
8.修改密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
可能会报一下错误,5.7版本必须包含大小写字母,数字和特殊字符
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements