ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost'

It was because i created the user using command :

CREATE USER 'user'@'%' IDENTIFIED BY 'passwd';

and i was deleting it using :

drop user 'user'@'localhost';

and i should have used this command :

drop user 'user'@'%';

It is likely that the user you are trying to drop does not exist. You can confirm (or not) whether this is the case by running:

select user,host
from mysql.user
where user = '<your-user>';

If the user does exist then try running:

flush privileges;

drop user 'user'@'localhost';

Another thing to check is to make sure you are logged in as root user

If all else fails then you can manually remove the user like this:

delete from mysql.user
where user='<your-user>'
and host = 'localhost';

flush privileges;

How to solve problem like this:

mysql> drop user 'q10'@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'q10'@'localhost'

First:you should check what host of your user,such as:


mysql> select host,user from user;
+-----------+------+
| host      | user |
+-----------+------+
| %         | q10  |
| localhost | root |
| localhost | sy   |
| localhost | tom  |
+-----------+------+

if I drop user 'q10',the command is :

mysql> drop user 'q10'@'%';
Query OK, 0 rows affected (0.00 sec)

And if I drop user 'tom',the command as follow:

mysql> drop user 'tom'@'localhost';
Query OK, 0 rows affected (0.00 sec)