首页 > 解决方案 > 错误 1698 (28000): 拒绝用户 'superuser1'@'localhost' 的访问

问题描述

我按照问题ERROR 1698 (28000): Access denied for user 'root'@'localhost'中选项 2 的说明进行操作, 并使用 superuser1 作为我的 'YOUR_SYSTEM_USER'(参见下面的代码)。

$ sudo mysql -u root 
mysql> USE mysql;
mysql> CREATE USER 'superuser1'@'localhost' IDENTIFIED BY '';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'superuser1'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='superuser1';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

现在我得到 ERROR 1698 (28000): Access denied for user 'superuser1'@'localhost' 当尝试按照该答案中的建议登录 mysql 时,即使我在 mysql 命令前面加上 sudo 也会出现此错误,如下所示

hms011@hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser1
[sudo] password for hms011: 
ERROR 1698 (28000): Access denied for user 'superuser1'@'localhost'
hms011@hms011-OptiPlex-9010-AIO:~$ 

我在新桌面安装上的 Linux Mint 19 上使用服务器版本:5.7.23-0ubuntu0.18.04.1 (Ubuntu)。作为一个新的 mysql 用户,我在创建用户时会有点试探性,直到我变得更加熟悉为止。我是否应该将我的 superuser1 的插件更改为 mysql_native_password?我遵循的解决方案建议对新用户不使用密码(即'') - 这会影响插件的任何更改吗?我确实看过问题MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)和大多数其他类似的问题,但看不到那里的任何建议将如何解决我的问题 -我最初的问题的建议解决方案确实包括使用我遵循的 FLUSH PRIVILEGES (正如我在一开始所说的那样)。我原来的问题(仍然存在)是ERROR 1698 (28000): Access denied for user 'root'@'localhost'与其他一些用户不同,在该线程中使用推荐的选项 2 无法解决此问题。因此我提出了我自己的问题,也许我在最初的描述中过于简洁,所以现在包含了上面提到的选项 2 解决方案的代码以及登录时产生的错误。

在没有任何帮助的情况下,我尝试过:

hms011@hms011-OptiPlex-9010-AIO:~$ sudo mysql -u root
[sudo] password for hms011: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all privileges on *.* to 'superuser1'@'localhost' identified by 'toFFee8_&cHeese' with grant option;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
hms011@hms011-OptiPlex-9010-AIO:~$ mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'@'localhost' (using     password: YES)

hms011@hms011-OptiPlex-9010-AIO:~$ sudo mysql -u superuser -p
Enter password: {password was entered}
ERROR 1045 (28000): Access denied for user 'superuser'@'localhost' (using password: YES)

所以现在我确实得到了 ERROR 1045 (28000),但对于它(或其他错误)发生的原因却一无所知。最后我回到'root'并重新授予超级用户1的所有权限我现在可以登录但没有设置的密码。虽然这似乎令人满意,但我更愿意知道为什么会这样,以便对我所做的事情有信心


解决了

最终整个问题似乎都解决了

'auth_socket' 是 root 的现有插件,但对于其他 Linux 用户,它可能是 'unix_socket';和 - 为“root”设置不包含“&”的密码

标签: mysqllocalhostrootaccess-denied

解决方案


推荐阅读