How To Use MySQL DROP USER to Delete a User Account in MySQL

3 min readMar 25, 2021

Summary: in this tutorial, you will learn how to use the MySQL DROP USER statement to remove one or more user accounts from the database.

Introduction to MySQL DROP USER statement

To remove a user account from the MySQL Server, you use the DROP USER statement as follows:

In this syntax, you specify the name of the user account that you want to remove after the DROP USER keywords.

If you want to remove multiple user accounts at once, you specify a list of comma-separated user accounts in the DROP USER clause:

If you remove a user account that doesn’t exist, MySQL will issue an error.

In MySQL 5.7.8+, you can use the IF EXISTS clause to conditionally drop a user only if it exists:

Besides removing the user account, the DROP USER statement also removes all privileges of the user from all grant tables.

MySQL DROP USER examples

Let’s take some examples of dropping users.

A) Using MySQL DROP USER statement to drop a user example

First, connect to the MySQL Server using the root account:

Type the password for the root user and press Enter:

Second, create four account users accounts api@localhost, remote, dbadmin@localhost and alice@localhost:

Third, show users from the MySQL Server:

Here is the current user list:

Fourth, drop the user dbadmin@localhost by using the DROP USER statement:

Fifth, show all users again:

The user account dbadmin@localhost has been removed successfully.

B) Using MySQL DROP USER to drop multiple user accounts at once

First, remove two user accounts api@localhost and remote using the following statement:

Second, show users from the current database:

Here is the output:

C) Using MySQL DROP USER to drop a connected user

First, create a new database called people: