How to Drop a User in MySQL
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
The best way to delete a user in MySQL is with the DROP USER command. This post walks you through it.
The DROP USER command is used to remove one or more MySQL user accounts and their privileges.
DROP USER [IF EXISTS] user_name@host_name;
IF EXISTS: Optional clause to prevent an error from occurring if the user does not exist.user_name@host_name: Specifies the username and the host from which they connect. The host name can be a specific IP, % for any host, or omitted for the default host.To remove a specific user, use the following command, replacing username and hostname with the appropriate values:
DROP USER username@hostname;
To delete multiple users in a single command, separate each user by a comma:
DROP USER user1@host1, user2@host2;
If you’re unsure whether a user exists, you can use IF EXISTS to avoid errors:
DROP USER IF EXISTS username@hostname;
You should probably revoke all of the user’s privileges before deleting them. That way they’ll lose access even if, for whatever reason, the deletion command fails.
REVOKE ALL PRIVILEGES, GRANT OPTION FROM username@hostname;
DROP USER username@hostname;
After deleting a user, it’s important to run the FLUSH PRIVILEGES command. This will make sure the changes are applied immediately.
FLUSH PRIVILEGES;
Before deletion, you may want to check the existing users. Use the following command:
SELECT User, Host FROM mysql.user;
For access management workflows, Basedash complements SQL controls with governed reporting, shared visibility, and AI-assisted analysis so teams can monitor permission changes without losing auditability.
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.