Difference between revisions of "How to Drop a User in MySQL"

From Brian Nelson Ramblings
Jump to: navigation, search
(Created page with "==How to Drop a User in MySQL== Adding a user is pretty simple, but they never tell you how to remove a user from the system. After removing an application from the server y...")
 
(Find the users accounts to remove)
Line 19: Line 19:
 
  | wordpress | 127.0.0.1            |
 
  | wordpress | 127.0.0.1            |
 
  | root      | ::1                  |
 
  | root      | ::1                  |
|          | localhost            |
 
 
  | brian    | localhost            |
 
  | brian    | localhost            |
 
  | root      | localhost            |
 
  | root      | localhost            |
| wodpress  | localhost            |
 
 
  | wordpress | localhost            |
 
  | wordpress | localhost            |
 
  +-----------+----------------------+
 
  +-----------+----------------------+

Revision as of 20:46, 16 May 2014

How to Drop a User in MySQL

Adding a user is pretty simple, but they never tell you how to remove a user from the system.

After removing an application from the server you will want to remove that user from MySQL as well.

Find the users accounts to remove

select user,host from mysql.user;

Output:

mysql> select user,host from mysql.user;
+-----------+----------------------+
| user      | host                 |
+-----------+----------------------+
| brian     | %                    |
| root      | 127.0.0.1            |
| wordpress | 127.0.0.1            |
| root      | ::1                  |
| brian     | localhost            |
| root      | localhost            |
| wordpress | localhost            |
+-----------+----------------------+

Now lets remove the wordpress user from MySQL.

Once logged into mysql as root run the following:

revoke all privileges, grant option from 'wordpress'@'127.0.0.1';
revoke all privileges, grant option from 'wordpress'@'localhost';
drop user 'wordpress'@'127.0.0.1';
drop user 'wordpress'@'localhost';