mysql重新创建用户时出现1396 - Operation CREATE USER failed;
flush PRIVILEGES 刷新权限后,用户能正常创建。
1. 查看当前用户
mysql> select user();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set
2.查看mysql的user表中是否存在用户testuser1
mysql> select host, user, password ,ssl_cipher, x509_issuer,x509_subject from user where user='testuser1';
+------+-----------+-------------------------------------------+------------+-------------+--------------+
| host | user | password | ssl_cipher | x509_issuer | x509_subject |
+------+-----------+-------------------------------------------+------------+-------------+--------------+
| % | testuser1 | *06C0BF5B64ECE2F648B5F048A71903906BA08E5C | | | |
+------+-----------+-------------------------------------------+------------+-------------+--------------+
1 row in set
3.删除user表中的用户testuser1
mysql> delete from user where user in ('testuser1');
Database changed
mysql> select host, user, password ,ssl_cipher, x509_issuer,x509_subject from user where user='testuser1';
Empty set
4. 创建用户testuser1时出现1396错误
mysql> create user testuser1@'%' identified by 'test1';
1396 - Operation CREATE USER failed for 'testuser1'@'%'
5.刷新权限
mysql> flush PRIVILEGES;
Query OK, 0 rows affected
6.用flush privileges 刷新后,重建用户testuser1,正常
mysql> create user testuser1@'%' identified by 'test1';
Database changed
7.查询user表,用户testuser1已经被创建
mysql> select host, user, password ,ssl_cipher, x509_issuer,x509_subject from user where user='testuser1';
+------+-----------+-------------------------------------------+------------+-------------+--------------+
| host | user | password | ssl_cipher | x509_issuer | x509_subject |
+------+-----------+-------------------------------------------+------------+-------------+--------------+
| % | testuser1 | *06C0BF5B64ECE2F648B5F048A71903906BA08E5C | | | |
+------+-----------+-------------------------------------------+------------+-------------+--------------+
1 row in set