The MySQL user is a record in the USER table of the MySQL server that contains the login information, account privileges, and host information for the MySQL account. It is essential to create a user in MySQL for accessing and managing the databases. To delete a MySQL user is to remove an account and its privileges from all grant tables. Only users with global CREATE USER or DELETE privileges can perform such tasks. Please refer to these related guides: A Review of the VMCE Training and Certification, how to Fix SmartScreen can’t be reached right now on Windows 10 and 11. And how to prevent Exe files from getting deleted randomly in Windows 10 and 11. In this article, you will learn how to delete a MySQL User Account.
When a MySQL Server installation completes, it comes with a ROOT user account by default which enables you to access and manage the databases. Most times, you would want to give the database access to others without granting them full control. In that case, you will create a non-root user and grant them specific privileges to access and modify the database. This is the user I will be showing you how to delete. Please refer to these exciting guides: How to upgrade ManageEngine Password Manager Pro, how to block the Change Password Feature for All Users via the Exchange Administrative Center, and how to use MySQL Workbench to download your MySQL database from Azure to the local computer.
Drop MySQL User Account
I will be showing you how to do this over the phpMyAdmin interface. Basically, these are the same steps to employ when using the command line. Firstly, I will be showing you the USER I would like to drop from the image below.
Next, run the following SQL query to display the user you want to remove by running a command that lists users from the MySQL server.
SELECT User, Host FROM mysql.user;
As you can see below, this is a list of all the available users on this server. To delete a MySQL user via the phpMyAdmin, simply click on the Delete button as shown below.
Confirm User Account Deletion
You will be prompted to confirm if you would like to delete the account. Click on Ok to have the MySQL user account deleted.
Please see the related articles. MySQL Workbench could not connect to the MySQL server, How to access MySQL Server from command Prompt, How to create and delete MySQL database, and How to import a MySQL Database via the command line.
See below. The account is no longer available on this MySQL server.
Via the command line
To do this via the command line, locate the name you want to remove. Replace the username in the following command with your user.
DROP USER 'username'@'host';
Remove Multiple MySQL Users
To delete multiple users at the same time. Use the same
DROP USER syntax. But this time, add users separated by a comma and a space.
DROP USER 'username1'@'localhost', 'username2'@'localhost', 'username2'@'localhost';
I hope you found this blog post helpful on how to delete a MySQL User Account. If you have any questions, please let me know in the comment section.