創建用戶的時候報告這個錯誤:mysql
ERROR 1396 (HY000): Operation CREATE USER failed for 'abc'@'localhost'sql
緣由是mysql中已經有了這個用戶,從mysql.user中直接刪除delete,而後刷新權限FLUSH PRIVILEGES,再建用戶就不會有這個問題了。ide
若是是drop user 的話,mysql內部會自動刷新一下,那麼再建也不會有這問題了。spa
舉例說明1——delete刪除:it
mysql> create user 'abc'@'localhost';io
Query OK, 0 rows affected (0.00 sec)class
mysql> select user,host from user;select
+------+-----------+權限
| user | host |di
+------+-----------+
| 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)