MySQL is an relational database management system provide authentication mechanism to prevent unauthorized access. It keeps all the user details in a database named “mysql”. You must have super user access (eg: root) to access this database.
In this article you will learn to find accounts in a MySQL server and remote unnecessary user accounts.
View Current Users
Connect to the existing MySQL server using administrative privileged account.
mysql -u root -p
Next, list all the available user account in MySQL server. Default database named “mysql” contains system related details including user account under “user” table.
SELECT User,Host FROM mysql.user;
List out the account with hostname to delete or all unused accounts no longer required.
Drop/Delete MySQL User
DROP USER statement is used to delete one or more accounts from MySQL. It also removes privilege rows for the account from all grant tables. You must have specified username along with hostname as per showing in above screenshot.
For example, to remove user “dummy” with host “localhost”, execute below query:
DROP USER 'dummy'@'localhost';
The above command drop only those user from MySQL maches both username and hostname.
Let’s use another example to delete user “myuser” with hostname “%”, execute below query.
DROP USER 'myuser'@'%';
That’s it. Repeat the same command to remove more accounts no longer required.
This tutorial describes you to how to remove user accounts from MySQL database server.