Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 352
user3086014 Avatar asked Dec 20 '13 07:12

user3086014


People also ask

What is ERROR 1396 in MySQL?

The MySQL ERROR 1396 occurs when MySQL failed in executing any statement related to user management, like CREATE USER or DROP USER statements. This error frequently appears when you run statements to create or remove users from your MySQL database server.


2 Answers

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'@'%';
like image 85
user3086014 Avatar answered Oct 14 '22 00:10

user3086014


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;
like image 39
Tom Mac Avatar answered Oct 14 '22 02:10

Tom Mac