//下载 [root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm //安装 [root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
[mysql-connectors-community] name=MySQL Connectors Community baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/ enabled=1 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql[mysql-5.6-community]
name=MySQL 5.6 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.6-community-el7-$basearch/
enabled=0
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-8.0-community]
name=MySQL 8.0 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
enabled=0//默认安装最新版本,因为自己要安装5.7,所有把enabled=1改成enabled=0
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
sudo yum install -y mysql-community-server
sudo service mysqld start
sudo service mysqld status
查看初始化密码:
sudo grep ‘temporary password‘ /var/log/mysqld.log
使用初始密码进行登录:
mysql -u root -p
初始化密码 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘初始化密码‘;
SHOW VARIABLES LIKE ‘validate_password%‘;
set global validate_password_policy=LOW;
set global validate_password_length=6;
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘123456‘;
//这里设置登录密码和远程连接密码都是123456
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
//刷新权限
FLUSH PRIVILEGES;
systemctl enable mysqld
firewall-cmd --zone=public --add-port=3306/tcp --permanent
//重启防火墙
firewall-cmd --reload
//验证3306是否开放成功
firewall-cmd --zone=public --query-port=3306/tcp
原文:https://www.cnblogs.com/menu520/p/14714178.html