DROP USERuser[,user] ...
The DROP USER statement removes one or more
MySQL accounts. To use it, you must have the global
CREATE USER privilege or 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. For additional
information about specifying account names, see
Section 12.5.1.3, “GRANT Syntax”.
DROP USER as present in MySQL 5.0.0 removes
only accounts that have no privileges. In MySQL 5.0.2, it was
modified to remove account privileges as well. This means that
the procedure for removing an account depends on your version of
MySQL.
As of MySQL 5.0.2, you can remove an account and its privileges as follows:
DROP USER user;
The statement removes privilege rows for the account from all grant tables.
Before MySQL 5.0.2, DROP USER serves only to
remove account rows from the user table for
accounts that have no privileges. To remove a MySQL account
completely (including all of its privileges), you should use the
following procedure, performing these steps in the order shown:
Use SHOW GRANTS to determine what
privileges the account has. See
Section 12.5.5.14, “SHOW GRANTS Syntax”.
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. See
Section 12.5.1.3, “GRANT Syntax”.
Delete the account by using DROP USER to
remove the user table row.
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. This is by design.
DROP USER does not automatically delete or
invalidate any database objects that the user created. This
applies to tables, views, stored routines, and triggers.

User Comments
Add your own comment.