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

解决MySQL登录失败问题
本文提供了一种解决MySQL登录失败的具体步骤,通过停止MySQL服务、绕过授权表启动、重置root用户密码等操作,最终成功解决Access denied for user 'root' @ 'localhost'的问题。

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

 

转载于:https://www.cnblogs.com/blibli/p/7292114.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值