. Advertisement .
..3..
. Advertisement .
..4..
The error 1396 (Hy000): operation create user failed for is a frequent bug in the MySQL system. There are several kinds of minor mistakes that can lead to such a failure.
Read on to learn more about what they are as well as how to debug the error.
Fixing Error 1396 (Hy000): Operation Create User Failed For
This is a bug that likely happens when you remove or create users in your MySQL database server. Check out these reasons below to thoroughly comprehend such a stumble!
Reason #1: Recreating A Deleted User
If you’re running the code and encounter an error like this, there is a chance the cause lies in your step to delete a user before.
That said, MySQL will not allow you to recreate that user you’ve removed by employing the DELETE command. If you insist on doing so, you must first apply a DROP USER statement for it.
The error will keep appearing, but do not rush to worry anyway. After that, you will be able to generate whichever user you wish to!
Here is an example:
CREATE USER `engineer` IDENTIFIED BY "engineer";
DELETE FROM mysql.user WHERE user = 'engineer';
Say you create the user engineer and then delete it later on using the DELETE command. The following problem will occur the next time you recreate this user in your database server:
mysql> DELETE FROM mysql.user WHERE user = 'engineer';
Query OK, 1 row affected (0.00 sec)
mysql> CREATE USER `developer` IDENTIFIED BY "engineer";
ERROR 1396 (HY000): Operation CREATE USER failed for 'engineer'@'%'
To solve this, you must adopt the DROP USER statement for the user. The error will continue to occur, but following that, you’ll be able to generate your desired user.
mysql> CREATE USER `engineer` IDENTIFIED BY "engineer";
ERROR 1396 (HY000): Operation CREATE USER failed for 'engineer'@'%'
mysql> DROP USER `engineer`;
ERROR 1396 (HY000): Operation DROP USER failed for 'engineer'@'%'
mysql> CREATE USER `developer` IDENTIFIED BY "engineer";
Query OK, 0 rows affected (0.01 sec)
Reason #2: Create An Already Existing User
You would probably get the fault if performing the CREATE USER command for an already existing user.
For instance:
mysql> CREATE USER `engineer` IDENTIFIED BY "engineer";
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE USER `engineer` IDENTIFIED BY "engineer";
ERROR 1396 (HY000): Operation CREATE USER failed for 'engineer'@'%'
Reason #3: Alter Or Drop A Non-existing User
You may bring forth the exact same error when executing the ALTER USER or DROP USER statement for a non-existent user account. Let’s view the illustration as follows:
mysql> DROP USER `notuser`;
ERROR 1396 (HY000): Operation DROP USER failed for 'notuser'@'%'
mysql> ALTER USER [email protected] IDENTIFIED BY 'newPassword';
ERROR 1396 (HY000): Operation ALTER USER failed for 'dev'@'localhost'
To fix this, you need to get a list of all existing users on your database server and see whether you stumble upon these above mistakes.
The Bottom Line
That is all about our in-depth instruction for you to cure the error 1396 (hy000): operation create user failed for. Hopefully, you’ve racked up some awesome insights. Also, don’t forget to stay tuned for our upcoming updates regarding other similar MySQL bugs!
Leave a comment