ERROR 1396 (HY000): Operation DROP USER failed for ‘user2’@’localhost’

ERROR 1396 (HY000): Operation DROP USER failed for ‘user2’@’localhost’

While executing the drop command I am getting the following error:

MariaDB [(none)]> drop user user2@'localhost';
ERROR 1396 (HY000): Operation DROP USER failed for 'user2'@'localhost'

Cause: On checking the user table in MySQL getting the following information, we are using the wrong host in command.

MariaDB [(none)]> select user,host from mysql.user;
+-------------+----------------+
| User        | Host           |
+-------------+----------------+
| TEST        | %              |
| TEST1       | %              |
| hr2         | %              |
| user2       | %              |

While the user is created as a ‘%’ host, you are using localhost while deleting the user. Modifying the query will fix the issue.

drop user user2@'%';

Example:
MariaDB [(none)]> drop user user2@'%';
Query OK, 0 rows affected (0.011 sec)
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.