建立用户的时候报告这个错误:
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