How To Delete MySQL Databases & Users From Your MySQL Server

In a previous article, we created a Remote MySQL Database Server on one of our NVMe VPS Servers, then we installed a copy of WordPress on a different server. We created a database and user and connected them. Now we are going to look at how we manage that user. Specifically, we want to learn how to delete the MySQL databases and how to delete MySQL users.

This guide will also work on MariaDB servers as MariaDB is basically a copy of MySQL. Login to your MySQL/MariaDB database server as the root user to proceed. Next, issue the below command to log in to MySQL. You will need to Reset The MySQL Root Password if you have forgotten it or you don’t know it.

mysql -u root -p mysql

List MySQL Users

Your console will now display mysql>. We can see a list of MySQL users on this server by issuing the following command;

delete mysql users
SELECT User,Host FROM mysql.user;

Delete MySQL Users

So, here we can see the database users that we created in the previous article, deltadb. This is the user that we want to delete from our MySQL server. To delete the user we use the DROP command.


So, our command to delete the deltadb user would be

DROP USER 'deltadb'@'localhost';
DROP USER 'deltadb'@'%';

Now, if we list all users on the server we can see the deltadb user has been removed.

delete mysql databases

Delete MySQL Databases

Now we have deleted the MySQL user we also want to delete the MySQL database. When you issue the next command all data in the database will be deleted. If you need a copy of the data Backup the MySQL database before issuing the command to delete.

First, list all of the databases on the MySQL/Mariadb server with the SHOW DATABASES; command.

We want to delete the delta and deltadb databases so again, we use the drop command to achieve this.


That’s the process complete. We have deleted the MySQL user we created in our previous guide and now we have also deleted the MySQL database.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button