Mysql error 1396 (HY000) wrong solution

Source: Internet
Author: User

This error is reported when creating a user:

ERROR 1396 (HY000): Operation CREATE USER failed for ' abc ' @ ' localhost '

The reason is that the user is already in MySQL, remove the delete directly from the Mysql.user, and then refresh the permissions flush privileges, then build the user will not have this problem.

If it is the drop user, MySQL will automatically refresh the internal, then the building will not have this problem.


For example, 1--delete 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)


Create a user with the same name again with the following error:

mysql> create user ' abc ' @ ' localhost ';

ERROR 1396 (HY000): Operation CREATE USER failed for ' abc ' @ ' localhost '

Here to refresh the permissions, after the refresh can be created;

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)



For example, 2--drop Delete can be created directly:

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)



This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://mofansheng.blog.51cto.com/8792265/1980514

Mysql error 1396 (HY000) wrong solution

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.