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; 

How to Delete A MySQL User Account drop mariadb mysql user

List out the account with hostname to delete or all unused accounts no longer required.

Drop/Delete MySQL User

Use 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';

How to Delete A MySQL User Account drop mariadb mysql user

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'@'%';

How to Delete A MySQL User Account drop mariadb mysql user

That’s it. Repeat the same command to remove more accounts no longer required.

Conclusion

This tutorial describes you to how to remove user accounts from MySQL database server.