MySQL Delete Database

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

MySQL Delete Database example

This example shows you how to perform using a command prompt. However, before we delete or drop any of them, Let me show you the list of available MySQL Databases. 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 DBs 1

The basic syntax to Delete or Drop a 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 was executed successfully. And it is saying that 1 row was affected. So, it means there is one table in that database, which is dropped (along with the Database).

MySQL Delete or drop Database 2

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

View DB 3

Delete or Drop the Database in MySQL 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 drop database statement or use the context menu.

Open the Workbench 4

Using Query in Workbench

In this example, we delete second_database using the MySQL Drop Database command.

DROP DATABASE second_database;

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

MySQL Delete or drop Database 5

Using Workbench GUI

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

Choose the Drop Schema Option n from Context Menu 6

Please select the Drop Now option.

Choose Review Code or Drop Now Option 7

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

MySQL Delete or drop Database 8

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

Best Way to Drop or Delete Database in MySQL

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

DROP DATABASE first_database;
Error Code 1008

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

Using If Exists to Check 10

Let me try a different name.

DROP DATABASE IF EXISTS fourth_database;
If Exists 11