Deleting a User in MySQL
From time to time you need to delete a user from MySQL. The task can be completed two ways depending on what version of MySQL you are using. The following describes both methods for deleting a user and their respective versions.
Note: You must be root to do this.
From MySQL 4.1.1 up, use DROP USER
Before MySQL 4.1.1:
mysql> select user, host from mysql.user;
+-------+--------------+
| user | host |
+-------+--------------+
| root | mydomain.org |
| joe_s | localhost |
| root | localhost |
| phil | localhost |
+-------+--------------+
mysql> revoke all privileges on *.* from phil@localhost;
mysql> revoke grant option on *.* from phil@localhost;
mysql> delete from mysql.user
-> where user=’phil’ and host=’localhost’;
mysql> flush privileges;
mysql> select user, host from mysql.user;
+-------+--------------+
| user | host |
+-------+--------------+
| root | mydomain.org |
| joe_s | localhost |
| root | localhost |
+-------+--------------+
For more information see the online MySQL manual.
Comments
Leave a Reply
You must be logged in to post a comment.