How to Remove MySQL Accounts

You might want to remove an account from a MySQL database. In most cases, having an account that no one uses doesn’t have any negative effects. However, if you think an account has been compromised, you might want to remove it for security reasons.

To remove an account, you can use the DROP USER statement (which was added in MySQL 4.1.1), as follows:

DROP USER accountname@hostname, accountname@hostname, ...

You must use an account that has DELETE privileges on the mysql database to execute the DROPUSER statement.

The behavior of DROP USER has changed through MySQL versions. As of MySQL 5.0.2, it removes the account and all records related to the account, including records that give the account privileges on specific databases or tables. However, in versions before MySQL 5.0.2, DROP USER drops only accounts that have no privileges.

Therefore, in older versions, you must remove all the privileges from an account, including database or table privileges, before you can drop that account.