How to Delete Mysql Database

Try it in our public cloud & Get $5 Credit
How to delete MySQL Database

In this tutorial, we will show you how to delete MySQL database on Ubuntu 18.04 server.

Creating and deleting the MySQL databases is a day-to-day task of any database administrator. You can delete the MySQL databases by using either a command-line interface or PhpMyAdmin web-based interface. In order to delete a MySQL database from your system, you must have a MySQL user account with delete privileges.


  • A server running Ubuntu 18.04 with MySQL and PhpMyAdmin installed.
  • MySQL user and password associated with the database or MySQL root password.

Delete MySQL Database with Mysqladmin

Mysqladmin is a MySQL command-line utility that can be used to perform some basic MySQL tasks including, creating and deleting databases, checking MySQL processes, Setting root password and many more.

Before deleting any database, list all available databases in your system with the following command:

mysqlshow -u root -proot-password

You should see the following output:

mysqlshow: [Warning] Using a password on the command line interface can be insecure.
 |     Databases      |
 | information_schema |
 | compressdb         |
 | mysql              |
 | performance_schema |
 | remotedb           |
 | sys                |
 | test1db            |
 | test2db            |
 | testdb             |

mysqlshow command to show all databases.

Next, delete the database named testdb from the above list by running the following command:

mysqladmin -u root -proot-password drop testdb

You should see the following output:

 Dropping the database is potentially a very bad thing to do.
 Any data stored in the database will be destroyed.
 Do you really want to drop the 'testdb' database [y/N] y
 Database "testdb" dropped

Delete a MySQL database using mysqladmin command.

Delete MySQL Database within MySQL Console

You can also drop the MySQL database after log into the MySQL console.

First, log into the MySQL console with root user with the following command:

mysql -u root -proot-password

Once login, you should see the following output:

 mysql: [Warning] Using a password on the command line interface can be insecure.
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 22
 Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)
 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
 Oracle is a registered trademark of Oracle Corporation and/or its
 affiliates. Other names may be trademarks of their respective
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Log into MySQL cli.

Next, list all available databases with the following command:

show databases;


 | Database           |
 | information_schema |
 | compressdb         |
 | mysql              |
 | performance_schema |
 | remotedb           |
 | sys                |
 | test1db            |
 | test2db            |
 8 rows in set (0.00 sec)

Result of show databases; into mysql cli.

Next, delete the MySQL database named test1db from the above list with the following command:

drop database test1db;

Next, exit from the MySQL console with the following command:


Delete MySQL database and exit from mysql cli.

You can also remove the MySQL database named test2db without log into the MySQL console as shown below:

mysql -u root -proot-password -e "drop database test2db";

Delete MySQL Database with PhpMyAdmin

First, open your web browser and access the PhpMyAdmin web UI. You should see the following page:

phpMyAdmin login screen.

Provide your MySQL root username, password and click on the Go button. You will be redirected to the PhpMyAdmin dashboard in the following page:

phpMyAdmin home screen.

Now, click on the Databases, you should see all the databases in the following page:

phpMyAdmin databases list.

Now, select the database you want to delete and click on the Drop button to delete the selected database. You will be prompt to confirm as shown below:

Confirm to delete MySQL database using phpMyAdmin.

Click on the OK button to delete the database.


In the above guide, you learned how to drop a MySQL database server with command-line and PhpMyAdmin. I hope this will helps you to perform your day-to-day operations.