MySQL MariaDB

MySQL DROP DATABASE

In MySQL server (RDMS), we can create multiple databases for different projects to maintain their data files, folder, and useful information. Additionally, the SQL query “DROP” can be used if we need to delete the database. Dropping a database removes the particular database from the MySQL server’s instance and deletes the physical disk files utilized by the database.

Moreover, if the deleted database files are offline when removed, the disk files will not be dropped. It requires deleting them manually by utilizing Windows Explorer.

This post will talk about the procedure to drop the database in MySQL.

How to DROP Databases in MySQL?

To drop the database in MySQL, follow the below-state procedure:

  • Open the terminal and connect it to the MySQL server through username and password.
  • View all the existing databases.
  • Choose one that you want to drop.
  • Run the “DROP DATABASE <database-name>;” command.

Step 1: Access MySQL Server

First, lunch the terminal and execute the following command to access MySQL through username and password:

mysql -u root -p

Step 2: Display Databases

Run the “SHOW” command to view all available databases from MySQL:

SHOW DATABASES;

According to the following output, multiple databases exist, and we have selected the highlighted database:

Step 3: DROP Database

Finally, use the “DROP” command to delete the previously selected “newdb” database:

DROP DATABASE newdb;

The output as “Query OK, ….” means the specified query has been executed successfully:

Step 4: Verify DROP Operation

Lastly, verify if the specified is deleted successfully or not, use the “SHOW” command:

SHOW DATABASES;

It can be observed that the particular database does not exist anymore in the list:

That’s all! We have provided the procedure to drop the database in MySQL.

Conclusion

To drop the database in MySQL, first, open the terminal and connect it to the MySQL server through username and password. Then, view all the existing databases and select one that you want to drop. After that, execute the “DROP DATABASE <database-name>;” command. This post explained the procedure to drop the database in MySQL.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.