我似乎无法重新创建一个我已经删除的简单用户,即使是MySQL的根用户。

我的案例:用户'jack'之前存在,但我从mysql中删除了它。用户才能重新创建它。我在那张桌子上没看到这东西的痕迹。如果我对其他一些随机用户名执行这个命令,比如'jimmy',它就能正常工作(就像它最初对'jack'所做的那样)。

我做了什么破坏用户'jack',我如何撤销这个破坏,以重新创建'jack'作为MySQL安装的有效用户?

参见下面的示例。(当然,最初,jack这个词从被创造到被移除之间有很长一段时间。)

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)

当前回答

我今天遇到了这个问题,我通过以下步骤解决了它:

1)手动在mysql.user中插入麻烦的用户提供的必填字段值

mysql> insert into user(Host, User, Password, ssl_type) 
   values ('localhost', 'jack', 'jack', 'ANY');

2)

mysql> select * from user where User = 'jack';
   1 row in set (0.00 sec)

3)。

mysql> drop user jack;
Query OK, 0 rows affected (0.00 sec)

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

C. mysql> create user 'jack' identified by 'jack';
Query OK, 0 rows affected (0.00 sec)

D. mysql> select Host, User, Password, ssl_type  from user where User = 'jack';
+-----------+-----------+-------------------------------------------+----------+
| Host      | User      | Password                                  | ssl_type |
+-----------+-----------+-------------------------------------------+----------+
| localhost | jack      | jack                                      | ANY      |
| %         | jack      | *45BB7035F11303D8F09B2877A00D2510DCE4D758 |          |
+-----------+-----------+-------------------------------------------+----------+
2 rows in set (0.00 sec)

4)。

mysql> delete from user 
 where User = 'nyse_user' and 
       Host = 'localhost' and 
       Password ='nyse';
Query OK, 1 row affected (0.00 sec)

B.

mysql> select Host, User, Password, ssl_type  from user where User = 'jack';
+------+-----------+-------------------------------------------+----------+
| Host | User      | Password                                  | ssl_type |
+------+-----------+-------------------------------------------+----------+
| %    | jack      | *45BB7035F11303D8F09B2877A00D2510DCE4D758 |          |
+------+-----------+-------------------------------------------+----------+
1 row in set (0.00 sec)

希望这能有所帮助。

其他回答

步骤1)打开MySQL命令行客户端。

步骤2:select user, host from mysql.user;

步骤3)删除用户:drop user username@localhost;

步骤4)再次使用MySQL GUI创建用户。

步骤5)现在问题解决了。

MySql的错误解决:错误码1396

Whenever you had try to run query which create a User as Shown Below. MySql> CREATE USER 'springstudent'@'localhost' IDENTIFIED BY 'springstudent'; GRANT ALL PRIVILEGES ON * . * TO 'springstudent'@'localhost'; But when you try to run query which create user within all previleges, Due to bug it create gives previleges without showing user Because of this Problem we need to use this script for flush priviledges MySql> drop user 'springstudent'@'localhost'; flush privileges; create user admin@localhost identified by 'admins_password' After deleting the user, there is need to flush the mysql privileges Then Create User again

Gotchaaa ....Solved ....

我最近得到了这个错误。

对我来说有用的是检查mysql工作台的“用户和特权”,并意识到user仍然存在。

从那里删除它之后,我就可以重新创建用户了。

如果你在mysql上使用DELETE语句。如果试图删除一个用户,然后尝试用CREATE user重新建立用户,将会得到一个1396错误。通过运行DROP USER 'username'@'host'来摆脱这个错误;

DELETE 
  FROM mysql.user 
 WHERE user = 'jack';

(你会得到1396个错误,如果你试图重新创建杰克)

CREATE USER 'jack'@'localhost' IDENTIFIED BY PASSWORD '*Fi47ytFF3CD5B14E7EjkjkkC1D3F8086A5C0-krn';

(通过运行DROP USER来摆脱这种情况)

DROP USER 'jack'@'localhost';

(我想FLUSH特权不会造成伤害,但肯定会先放弃用户。)

检查是否

“用户”@“%”

or

’user’@’localhost’