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

想进入数据库,发现进不了,报错Access denied for user 'root'@'localhost' (using password: YES)

试了很多方法都不行,后来还是解决了

解决方法:

1.先停止mysql

shell># service mysqld stop

2.这段代码的意思大概是在启动
mysql时不启动grant-tables,授权表

shell># mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

 3.进入mysql

shell》# mysql -uroot mysql

4.查看数据库,是否存在mysql数据库并选择mysql数据库

mysql> show databases

mysql> use mysql

5.删除user为空的数据

mysql> delete from user where user='';

6.重设密码

mysql> update user set Password=PASSWORD('你想要设置的密码') where user='root';

7.刷新权限

mysql> flush privileges;

8.退出

mysql> exit;

9.重启mysql

shell># service mysqld restart

10.测试,搞定!

 

posted @ 2017-08-07 00:19  郭德纲又打人了嘿  阅读(776)  评论(0编辑  收藏  举报