[MySQL] User Deletion Should Be Done with DROP USER, Not DELETE Statement

Tadashi Shigeoka ·  Sun, September 11, 2011

When I tried to delete an existing user in MySQL and recreate one with the same username, an error occurred.

MySQL

I referenced the following site for the method to delete users:

mysql> use mysql
Database changed

mysql> delete from user where user='shige';
Query OK, 1 row affected (0.00 sec)

mysql> create user 'shige' identified by 'passwd';
ERROR 1396 (HY000): Operation CREATE USER failed for 'shige'@'%'

According to the article below, user deletion must be done with drop user.

After using drop user and then create, I was able to create the user successfully.

mysql> drop user shige;
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'shige' identified by 'passwd';
Query OK, 0 rows affected (0.00 sec)

That’s all from the Gemba.