mysql – ERROR 1396 (HY000): Operation CREATE USER failed for [email protected]

mysql – ERROR 1396 (HY000): Operation CREATE USER failed for [email protected]

yes this bug is there. However, I found a small workaround.

  • Assume the user is there, so drop the user
  • After deleting the user, there is need to flush the mysql privileges
  • Now create the user.

That should solve it. Assuming we want to create the user admin @ localhost, these would be the commands:

drop user [email protected];
flush privileges;
create user [email protected] identified by admins_password


Try doing a FLUSH PRIVILEGES;. This MySQL bug post on that error code appears to report some success in a case similar to yours after flushing privs. 

mysql – ERROR 1396 (HY000): Operation CREATE USER failed for [email protected]

This bug has been sitting on since 2007 and this thread is mainly just a parroting of all those wrong answers even up to a year ago.

According to the MySQL documentation, commands like CREATE USER, GRANT, REVOKE, and DROP USER do not require a subsequent FLUSH PRIVILEGES command. Its quite clear why, if one reads the docs. Its because altering the MySQL tables directly does not reload the info into memory; yet the plethora of solutions to this bug claim that FLUSH PRIVILEGES is the answer.

This also may not even be a bug. It is a documentation conspiracy – docs vary in one critical place from version to version. DROP USER Syntax

DROP USER user [, user] …

DROP USER [email protected];

If you specify only the user name part of the account name, a host name part of % is used.

DROP USER as present in MySQL 5.0.0 removes only accounts that have no privileges. In MySQL 5.0.2, it was modified to remove account privileges as well. This means that the procedure for removing an account depends on your version of MySQL.

As of MySQL 5.0.2, you can remove an account and its privileges as follows:


The statement removes privilege rows for the account from all grant tables.

The only time I get this error is when I do DROP USER user; like the doc suggests, but MySQL does not treat the % as a wildcard in a way that would drop all users at all hosts. Its not so wild after all. Or, it may be that it sometimes works when it deletes the localhost user and then tries to delete the one at %.

Its clear to me that when it tries to delete the user at %, it issues an error message and quits. Subsequent CREATE USER at localhost will fail because the localhost user was never deleted. There seems to be no need to waste time digging in the grant tables looking for ghosts as one poster suggested.

I see 7 votes for:

DROP USER [email protected]; // completely delete the account

Which is interpreted as DROP USER [email protected]@%; # wrong

There actually seems to be a real bug that generates the same error message, but it has to do with the first created user (after a new mysql server install) being dropped. Whether that bug has been fixed, I dont know; but I dont recall that happening lately and Im up to ver 5.5.27 at this time.

Leave a Reply

Your email address will not be published.