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

时间:2017-08-07 00:55:47   收藏:0   阅读:357

想进入数据库,发现进不了,报错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.测试,搞定!

技术分享

 

原文:http://www.cnblogs.com/blibli/p/7292114.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!