码迷,mamicode.com
首页 > 数据库 > 详细

Mysql ERROR 1396 (HY000) 错误的解决办法

时间:2017-11-10 10:57:16      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:mysql 1396

建立用户的时候报告这个错误:

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)



本文出自 “模范生的学习博客” 博客,请务必保留此出处http://mofansheng.blog.51cto.com/8792265/1980514

Mysql ERROR 1396 (HY000) 错误的解决办法

标签:mysql 1396

原文地址:http://mofansheng.blog.51cto.com/8792265/1980514

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!