下文给大家带来关于Mysql出现 ERROR 1396 (HY000) 报错该如何解决,感兴趣的话就一起来看看这篇文章吧,相信看完Mysql出现 ERROR 1396 (HY000) 报错该如何解决对大家多少有点帮助吧。
建立用户的时候报告这个错误:
ERROR 1396 (HY000): Operation CREATE USER failed for 'abc'@'localhost'
原因是mysql中已经有了这个用户,从mysql.user中直接删除delete,然后刷新权限FLUSH PRIVILEGES,再建用户就不会有这个问题了。
如果是drop user 的话,mysql内部会自动刷新一下,那么再建也不会有这问题了。
举例说明1——delete删除:
mysql> create user 'abc'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| abc | localhost |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)
mysql> delete from user where user='abc';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
再次创建同名用户,报错如下:
mysql> create user 'abc'@'localhost';
ERROR 1396 (HY000): Operation CREATE USER failed for 'abc'@'localhost'
这里要刷新权限,刷新之后就可以创建了;
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'abc'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| abc | localhost |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)
举例说明2——drop 删除,可以直接创建:
mysql> drop user 'abc'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)
mysql> create user 'abc'@'loaclhost';
Query OK, 0 rows affected (0.00 sec)
看了以上关于Mysql出现 ERROR 1396 (HY000) 报错该如何解决详细内容,是否有所收获。如果想要了解更多相关,可以继续关注我们的行业资讯板块。