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)
本文出自 “模範生的學習博客” 博客,請務必保留此出處http://mofansheng.blog.51cto.com/8792265/1980514
Mysql ERROR 1396 (HY000) 錯誤的解決辦法