1、下载mysql的yum源配置
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2、安装mysql的yum源
yum -y install mysql57-community-release-el7-11.noarch.rpm
3、使用yum方式安装mysql
yum -y install mysql-server
4、如果3报错
执行:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
然后再次执行:
yum -y install mysql-server
5、启动mysql并查看状态
systemctl start mysqld.service
systemctl status mysqld.service
6、获取临时密码
cat /var/log/mysqld.log | grep password
7、修改密码
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root123456';
如果密码太过简单则修改验证强度等级:
set global validate_password_policy=LOW;
修改密码长度:
set global validate_password_length=6;
8、设置远程访问
grant all privileges on *.* to 'root'@'%' identified by 'root123456' with grant option;
flush privileges;