Dropping a User in MYSQL Database

PROCEDURE OF DROPPING A USER:

Syntax:


DROP USER user [, user] ...
 
Example:


mysql> drop user gsmc_monitor;
Query OK, 0 rows affected (0.00 sec)
 
The DROP USER statement removes one or more MySQL accounts. To use it, you must have the DELETE privilege for the mysql database. Each account is named using the same format as for the GRANT statement; for example, 'jeffrey'@'localhost'. If you specify only the username part of the account name, a hostname part of '%' is used..


To remove a MySQL account completely (including all of its privileges), you should use the following procedure, performing the steps in the order shown:

1.Use SHOW GRANTS to determine what privileges the account has.

2.Use REVOKE to revoke the privileges displayed by SHOW GRANTS. This removes rows for the account from all the grant tables except the user table, and revokes any global privileges listed in the user table.

3.Delete the account by using DROP USER to remove the user table row.

In MySQL 5.0.2 and up, DROP USER removes the account row in the user table and also revokes the privileges held by the account.

Important:

DROP USER does not automatically close any open user sessions. Rather, in the event that a user with an open session is dropped, the statement does not take effect until that user's session is closed. Once the session is closed, the user is dropped, and that user's next attempt to log in will fail.

1 Response to "Dropping a User in MYSQL Database"

  1. This post explain how to drop a user in mysql. The steps for performing this function are given in the post and with this what privileges you need are also explained. Using this command you can delete more than one user accounts. So be careful while using it.

Post a Comment

Powered by Blogger