Reputation: 50
I mistakenly created a user that I am unable to delete. Following is the code snippet interacting with MySQL:
mysql> DROP User 'netbeansuser'@'%';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'@'%'
mysql> select User from mysql.user;
+------------------+
| User |
+------------------+
| root |
| root |
| debian-sys-maint |
| netbeansuser |
| root |
| root |
+------------------+
6 rows in set (0.00 sec)
mysql> DROP User 'netbeansuser';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'@'%'
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> select User from mysql.user;
+------------------+
| User |
+------------------+
| root |
| root |
| debian-sys-maint |
| netbeansuser |
| root |
| root |
+------------------+
6 rows in set (0.00 sec)
mysql> DROP User 'netbeansuser';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'@'%'
mysql> DROP User 'netbeansuser'@'%';
ERROR 1396 (HY000): Operation DROP USER failed for 'netbeansuser'@'%'
What am I doing wrong? Particularly, what is the '%' sign at the hostname for? I didn't specify the hostname while creating the user. Any resources on understanding hostname bindings in MySQL USER creation will also help. Thanks all.
Upvotes: 0
Views: 1332
Reputation: 1
I created the user john
with the host localhost
as shown below:
CREATE USER 'john'@'localhost';
But, I did not specify localhost
to drop the user john
as shown below:
DROP USER john;
Then, I got the error below:
ERROR 1396 (HY000): Operation DROP USER failed for 'john'@'%'
So, I specified localhost
as shown below, then I could drop the user john
without error:
DROP USER 'john'@'localhost';
Or:
DROP USER john@localhost;
Upvotes: 0