简体   繁体   English

MySQL | 无法使用root @ localhost登录,拒绝访问

[英]MySQL | Can't login with root@localhost, acces denied

I think i'm stuck. 我想我被卡住了。 Got MySQL server running great, when suddenly i lost access to it. MySQL服务器运行得很好,突然间我无法访问它。 It gives error 它给出了错误

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

Also I can't login through phpmyadmin (incorrect password). 另外,我无法通过phpmyadmin登录(密码错误)。

I've managed to use skip-grant-tables option to log in and see what's going on. 我已经设法使用skip-grant-tables选项登录并查看发生了什么。 Here is the mysql.user table: 这是mysql.user表:

| user | host +------+--------- | root | 127.0.0.1 | root | 195.14.50.18 | root | dlink-A9592D|

Also, SELECT PASSWORD=('my password here') gives the same hash as in the users table. 同样, SELECT PASSWORD=('my password here')给出的哈希值与用户表中的哈希值相同。

What am i doing wrong? 我究竟做错了什么? Everything looks correct, except I can't login with correct password. 一切看起来都正确,但我无法使用正确的密码登录。

I've already tried to update users with new password (even empty, still doesnt work). 我已经尝试用新密码更新用户(即使为空,仍然无法使用)。 Can't find answer in similar threads, so I'm asking here again. 在类似的线程中找不到答案,因此我再次在这里提问。

upd. 更新。 tried to remove mysql completely and install it again. 尝试完全删除mysql,然后重新安装。 And here is some magic: 这是一些魔术:

In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password : YES)

With any password (blank, old, any other) 使用任何密码(空白,旧密码或其他密码)

Solution that worked for me: 对我有用的解决方案:
1. restart mysql with skip-grant-tables included in my.cnf; 1.使用my.cnf中包含的skip-grant-tables重新启动mysql;
2. drop all users; 2.删除所有用户;
3. create new user and give all privileges 3.创建新用户并赋予所有特权

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM