登录mysql数据的时候:mysql -uroot -p

出现:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

首先去编辑 vi /etc/my.cnf[mysqld]下找一行,加上skip-grant-tables跳过检验

然后重启mysql:service mysqld restart

再次登录mysql:mysql -uroot -p   (注意:不要输入密码,直接回车(Enter))

MySql 解决方案:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

出现提示:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

mysql> flush privileges;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

mysql> flush privileges;

mysql> quit

到这里就已经重置成新的密码成功了。

然后再去编辑 vi /etc/my.cnf 注解skip-grant-tables

MySql 解决方案:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

最后重启mysql:service mysqld restart

 

相关文章: