gpt4 book ai didi

mysql - 错误 1045 (28000) : Access denied for user 'root' @'%'

转载 作者:行者123 更新时间:2023-11-29 01:52:59 25 4
gpt4 key购买 nike

我在努力奔跑

授予 * 上的所有特权。 * TO 'root'@'localhost';

从远程服务器到 localhost/phpmyadmin 但出现错误 1045 (28000): Access denied for user 'root'@'%' (using password: NO).

mysql> show grants;
+----------------------------------+
| Grants for root@% |
+----------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%' |
+----------------------------------+

我该如何解决这个问题?我已经通过互联网浏览了很多建议,但实际上无法弄清楚。

最佳答案

我想,您忘记了 flush privileges

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' with GRANT OPTION;
mysql> FLUSH PRIVILEGES;

注意:我已经包含了 with GRANT OPTION 因为正如文档所说:

The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.

编辑 1:

根据评论,您似乎忘记了 root 密码。所以尝试像这样重置:

  1. 停止 MySQL 服务器。

    sudo/etc/init.d/mysql 停止

  2. 免密码启动mysql

    sudo mysqld_safe --skip-grant-tables &

  3. root 身份登录到 mysql:

    mysql -u root

  4. 设置新密码为root

    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';

  5. 刷新权限。

    刷新权限;

  6. 最后,正常重启mysql。

关于mysql - 错误 1045 (28000) : Access denied for user 'root' @'%' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36395296/

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