Purpose
This statement is used to drop one or more database users.
Notice
- You must have the global
CREATE USERprivilege to use theDROP USERcommand. - You cannot delete the
mysql.usertable using theDELETEstatement. You must use theDROPstatement instead. - After a user is successfully deleted, all permissions associated with that user are also deleted.
Syntax
DROP USER [IF EXISTS] user_name [, user_name...]
Parameters
Parameters |
Description |
|---|---|
| IF EXISTS | Optional. When this clause is used, attempting to delete a non-existent user will generate a warning rather than an error. If this clause is not used, deleting a non-existent user will cause an error. |
| user_name | Username. Separate multiple usernames with commas when deleting them simultaneously. |
Examples
- Drop the user
sales_user.
obclient> DROP USER sales_user;
- When you use
IF EXISTSto delete a user, no error is returned if the user does not exist.
obclient> DROP USER IF EXISTS finance_user;
- Delete multiple users simultaneously.
obclient> DROP USER user1, user2, user3;