gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 23:45:41 25 4
gpt4 key购买 nike

我想我被困住了。 MySQL 服务器运行良好,但突然我无法访问它。它给出了错误

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

我也无法通过 phpmyadmin 登录(密码不正确)。

我已经设法使用skip-grant-tables选项登录并查看发生了什么。这是 mysql.user 表:

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

此外,SELECT PASSWORD=('my password here')给出与用户表中相同的哈希值。

我做错了什么?一切看起来都正确,但我无法使用正确的密码登录。

我已经尝试使用新密码更新用户(即使为空,仍然不起作用)。在类似的帖子中找不到答案,所以我再次在这里提问。

更新。尝试完全删除mysql并重新安装。这里有一些魔法:

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.<br/>
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password
: YES)

使用任何密码(空白、旧密码、任何其他密码)

最佳答案

对我有用的解决方案:
1. 重启mysql,并在my.cnf中包含skip-grant-tables;
2.删除所有用户;
3.创建新用户并赋予所有权限

关于MySQL |无法使用 root@localhost 登录,访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25965602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com