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

Viewed 91541

I have created a user in mysql. Now i want to delete the user ? How to do that? I am getting this error :

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

I am using this command :

DROP USER 'user'@'localhost';

Its an amazon machine.

Thanks

5 Answers

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)

Try using 'user'@'localhost' without quotes:

DROP USER user@localhost;

It should work that way in MySQL 8. I also had that problem.

delete from mysql.user where user='user_name' and host = 'localhost';

flush privileges;

Working for me...

Related