Purpose
This statement is used to delete one or more database users.
Notice
- You must have the global
CREATE USERprivilege to use theDROP USERcommand. - You cannot delete data from the
mysql.usertable using theDELETEstatement. You can only use theDROPstatement to delete users. - When a user is successfully deleted, all their privileges are also revoked.
Syntax
DROP USER [IF EXISTS] user_name [, user_name...]
Parameters
| Parameter | Description |
|---|---|
| IF EXISTS | Optional. When this clause is used, attempting to delete a non-existent user will generate a warning instead of an error. If this clause is not used, attempting to delete a non-existent user will result in an error. |
| user_name | The username. When deleting multiple users, separate them with commas. |
Examples
- Delete the user
sales_user.
obclient> DROP USER sales_user;
- Use
IF EXISTSto delete a user without generating an error if the user does not exist.
obclient> DROP USER IF EXISTS finance_user;
- Delete multiple users at once.
obclient> DROP USER user1, user2, user3;
