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

564次阅读
没有评论

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即可。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python教程2022-10-19发表,共计605字。
新手QQ群:570568346,欢迎进群讨论 Python51学习