1、下载mysql官方yum repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2、安装yum repository
安装
yum -y install mysql57-community-release-el7-10.noarch.rpm
3、安装mysql服务
rpm —import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql-community-server
4、启动mysql
systemctl start mysqld.service
5、获取mysql随机密码
grep “password” /var/log/mysqld.log
6、连接数据库
mysql -u root -p
- 右键复制并粘贴的随机密码
7、修改mysql密码规则
set global validate_password_policy=0;
set global validate_password_length=1;
8、修改mysql密码
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘fanmao888’;
9、允许远程用户连接
grant all privileges on . to ‘root’@’%’ identified by ‘fanmao888’ with grant option;
flush privileges;
- 断开mysql连接
exit;