1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| service mysqld start 启动MySQL服务 service mysqld status 查看MySQL服务状态
grep "A temporary password" /var/log/mysqld.log 查看初始密码
mysql -u root -p 然后输入初始密码
设置密码规则 set global validate_password.length=1; set global validate_password.policy=0; set global validate_password.check_user_name=off;
如果修改密码规则报错 set global validate_password_policy=LOW; set global validate_password_length=6;
更改密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
创建远程用户并授权 CREATE USER 'root'@'%' IDENTIFIED BY '密码'; grant all privileges on *.* to 'root'@'%' ;
将密码改为原始规则 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码'; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
|