CentOS下MySQL默认密码忘记怎么办?
CentOS下MySQL默认密码忘记的解决方法:
1、使用“grep' temporary password' /var/log/mysqld.log”找回安装时的初始密码; 2、使用centos系统账号和密码强制登陆,然后进行密码的修改即可。
方法一、找回安装时的初始密码:
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;