问题描述
我似乎无法重新创建一个已删除的简单用户,即使是在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.
这篇关于错误1396(HY000):操作CREATE USER对于'jack'@'localhost'失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!