一、安装MySQL
1.修改文件
vim /etc/yum.repos.d/mysql-community.repo
修改的内容时
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=1
gpgcheck=0
2.安装
yum -y install mysql-community-server
3.启动
systemctl start mysqld
4.获取初始密码
grep 'temporary password' /var/log/mysqld.log
二、修改密码
1.查看MySQL完整的初始密码规则
mysql> SHOW VARIABLES LIKE 'validate_password%';
2.修改规则
set global validate_password_length=4;
set global validate_password_policy=0;
(注意:global validate_password_length不太版本不一样,参考上面1的规则)
3.修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'f@]-ejik4p5>ae2';
三、允许远程连接
1.update user set host='%' where user='root';
2.flush privileges;