1.查找初始密码
cat /var/log/mysqld.log | grep password
2.登录到mysql
3.修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'Mysql1234!';
3-1 设置密码的检查机制
–修改策略
5.0
set global validate_password_policy=0;
set global validate_password_length=1;
8.0
set global validate_password.policy=0;
set global validate_password.length=4;
修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY '1234';
授权远程登陆
create user 'root'@'%' identified by '1234';
grant all privileges on *.* to 'root'@'%' with grant option;
flush PRIVILEGES;
修改防火墙打开3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
重启防火墙
systemctl restart firewalld