您好,欢迎来到花图问答。
搜索
您的当前位置:首页mysql输入正确密码连接不上怎么办

mysql输入正确密码连接不上怎么办

来源:花图问答

问题还原:

(推荐教程:)

登录

mysql -uroot -proot

报错:

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

解决思路:

排查1:

直接输入mysql,连接成功show databases; 只有information_schema & test两张表查了下说是权限不够。

排查2:

首先stop mysql:

service mysqld stop;

然后安全模式启动;

mysqld_safe --skip-grant-tables &

接着使用root登陆mysql :

mysql  root mysqluse mysql;
select Host,User,Password from user;

发现localhost这个Host没有配置用户名和密码。

解决方法:

update user set Password='root', User='root' where Host='localhost';
select Host,User,Password from user;

现在localhost已经有了对应的用户名和密码,kill掉mysqld_safe,重新启动mysql即可。

Copyright © 2019-2025 huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务