centos 7忘记mysql的密码

方法一、找回安装是的初始密码:

 1、grep 'temporary password' /var/log/mysqld.log

方法二、使用操作系统账号和密码,进行修改密码

1、mysql -uroot -p

2、输入你的centos的密码

3、UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';

注:如果显示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements,说明你的密码不符合安全要求,

4、FLUSH PRIVILEGES;

5、quit;

方法三、强制进行修改密码

1、systemctl stop mysqld

2、systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3、systemctl start mysqld

4、mysql -u root

5、UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';

注:如果显示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements,说明你的密码不符合安全要求,

6、FLUSH PRIVILEGES;

7、quit;
--------------------- 
原文:https://blog.csdn.net/wengzilai/article/details/78871414 
 

猜你喜欢

转载自blog.csdn.net/qq_34815528/article/details/88884615