MySQL Delete Database

The MySQL Drop Database is used to drop all the tables present in it and also deletes the database itself. Let us see how to Delete Database in MySQL with an example, and here we will use both command prompt and Workbench.

MySQL Delete Database example

In this example, we will show you how to delete a database in MySQL using a command prompt. Before we start deleting any of them, Let me show you the list of available Databases in MySQL. To get this information, you have to use the SHOW DATABASES command.


The following screenshot will show you the list of available dbs.

List of Databases 1

The basic syntax to Delete or Drop Database in MySQL is:


For the demonstration of this drop purpose, we are going to delete the First_Database. So, Replace the Database_Name with First_Database, as shown below.

DROP DATABASE First_Database;

From the below screenshot, you can see that the command executed successfully. And it is saying that 1 row affected. It means, there is one table in that MySQL database, and that table is dropped (along with the Database).

MySQL Delete Database 2

Now, let me show you the dbs available. And you can see the first_database is not on the list.

View Databases 3

MySQL Delete Database in Workbench

To delete a database, let me open the Workbench. From the below screenshot, you can see the list of the available ones under the Schemas pane. Here, there are multiple ways to delete them in a Workbench. Either you can write a MySQL drop database statement or use the context menu.

MySQL Delete Database 4

MySQL Drop Database using Query in Workbench

In this example, we delete second_database using Drop command

DROP DATABASE second_database;

Here, the command executed successfully. Now, you can see there is no second_database under schemas

MySQL Delete Database 5

Drop Database using Workbench GUI

To delete or drop, Under the SCHEMAS section, Please navigate yourself to the MySQL database that you want to drop. Right-click on it will open the context menu. Please select Drop Schema…. option from the context menu.

MySQL Delete Database 6

Please select Drop Now option.

MySQL Delete Database 7

Now you can see, there is no third_database under the schemas.

MySQL Delete Database 8

TIP: Please click on the refresh button beside the Schemas to see updated SCHEMAS.

Best way to Delete Database

Let us see what will happen if we drop a non-existing using MySQL drop database statement. From the below screenshot, you can observe that it is throwing an error saying: Can’t drop first_database. The db doesn’t exist.

DROP DATABASE first_database;
Error Code 1008. Can't drop Database 9

The following statement will only execute Drop Database Statement if the first_database in available in the system.

MySQL Delete Database 10

Let me try a different name with MySQL drop database command

DROP DATABASE IF EXISTS fourth_database;
MySQL Delete Database 11