错误 1396 (HY000):操作 CREATE USER 对 'jack'@'localhost' 失败

2021-11-20 00:00:00 mysql mysql-management

我似乎无法重新创建我删除的简单用户,即使是 MySQL 中的 root 用户.

I seem to be unable to re-create a simple user I've deleted, even as root in MySQL.

我的情况:用户 'jack' 以前存在过,但我从 mysql.user 中删除了它以重新创建它.我在那个桌子上看不到这方面的痕迹.如果我为其他一些随机用户名执行此命令,例如jimmy",它可以正常工作(就像它最初对jack"所做的一样).

My case: user 'jack' existed before, but I deleted it from mysql.user in order to recreate it. I see no vestiges of this in that table. If I execute this command for some other, random username, say 'jimmy', it works fine (just as it originally did for 'jack').

我做了什么来破坏用户 'jack' 以及如何撤消该损坏以便重新创建 'jack' 作为此 MySQL 安装的有效用户?

What have I done to corrupt user 'jack' and how can I undo that corruption in order to re-create 'jack' as a valid user for this installation of MySQL?

请参见下面的示例.(当然,最初,'jack'的创建和他的删除之间有很多时间.)

See example below. (Of course, originally, there was much time between the creation of 'jack' and his removal.)

mysql> CREATE USER 'jack'@'localhost' IDENTIFIED BY 'test123';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from user;
+------------------+-----------------+
| user             | host            |
+------------------+-----------------+
| root             | 127.0.0.1       |
| debian-sys-maint | localhost       |
| jack             | localhost       |
| root             | localhost       |
| root             | russ-elite-book |
+------------------+-----------------+
5 rows in set (0.00 sec)

mysql> delete from user where user = 'jack';
Query OK, 1 row affected (0.00 sec)

mysql> select user,host from user;
+------------------+-----------------+
| user             | host            |
+------------------+-----------------+
| root             | 127.0.0.1       |
| debian-sys-maint | localhost       |
| root             | localhost       |
| root             | russ-elite-book |
+------------------+-----------------+
4 rows in set (0.00 sec)

mysql> CREATE USER 'jack'@'localhost' IDENTIFIED BY 'test123';
ERROR 1396 (HY000): Operation CREATE USER failed for 'jack'@'localhost'
mysql> CREATE USER 'jimmy'@'localhost' IDENTIFIED BY 'test123';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from user;
+------------------+-----------------+
| user             | host            |
+------------------+-----------------+
| root             | 127.0.0.1       |
| debian-sys-maint | localhost       |
| jimmy            | localhost       |
| root             | localhost       |
| root             | russ-elite-book |
+------------------+-----------------+
5 rows in set (0.00 sec)

推荐答案

尝试做一个 FLUSH PRIVILEGES;.关于该错误代码的这个 MySQL 错误帖子 似乎在类似的情况下报告了一些成功刷新 privs 后到你的.

Try doing a FLUSH PRIVILEGES;. This MySQL bug post on that error code appears to report some success in a case similar to yours after flushing privs. 

相关文章