MySQL database can use the DROP USER statement to remove one or more user accounts and associated permissions.
Syntax:
DROP USER <user name 1> [, <username 2>] ...
Use DROP USER statement should note the following:
- DROP USER statement can be used to delete one or more MySQL accounts and to withdraw its original permissions.
- Use DROP USER statement must have in MySQL MySQL database DELETE privileges or global CREATE USER privilege.
- Using DROP USER statement, if not explicitly give the host name of the account, the host name defaults to "%."
Note: Delete does not affect the user before they create tables, indexes or other database objects, because MySQL does not record who created these objects.
[Examples] using DROP USER statement to delete user 'jack' @ 'localhost'. As shown in SQL statements and execution of the following forms.
mysql> DROP USER 'jack'@'localhost'; Query OK, 0 rows affected (0.00 sec)
In the Windows command-line tool, use the jack lion and password to log database server, login failures found, indicating that the user has been deleted, as shown below.
C:UsersUSER>mysql -h localhost -u jack -p Enter password: **** ERROR 1045 (28000)