gpt4 book ai didi

mysql - 错误 1396 (HY000) : Operation CREATE USER failed for 'jack' @'localhost'

转载 作者:IT老高 更新时间:2023-10-28 12:48:05 28 4
gpt4 key购买 nike

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

我的情况:用户 'jack' 以前存在,但我从 mysql.user 中删除了它以便重新创建它。我在那张 table 上看不到任何痕迹。如果我为其他一些随机用户名执行此命令,例如“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)

最佳答案

是的,这个错误就在那里。不过,我找到了一个小解决方法。

  • 假设用户在那里,所以删除用户
  • 删除用户后,需要刷新mysql权限
  • 现在创建用户。

这应该可以解决。假设我们要创建用户 admin@localhost,这些将是命令:

drop user admin@localhost;flush privileges;create user admin@localhost identified by 'admins_password'

干杯

关于mysql - 错误 1396 (HY000) : Operation CREATE USER failed for 'jack' @'localhost' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5555328/

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