Home > How To > How To Delete Database In MySQL

How To Delete Database In MySQL

Recently we learned about how to create a database in MySQL.  Now in this post, we will learn about how to delete database in MySQL.  Deleting a database in MySQL is easy but keep in mind that you will lose all data which is stored in the MySQL database. So keep the practice of keeping a backup for your database before deleting it.

How To Delete Database In MySQL

If you are a workbench user you can delete the MySQL database using workbench. In case you are a Linux user then you need to use a terminal to execute a command to drop or delete the MySQL database.

how to delete a database in MySQL workbench

  1. Launch workbench on your PC/laptop
  2. Login with the root user privilege.
  3. Now run the DROP DATABASE [IF EXISTS] database_name;
  4. In the above command, You determine the name of the database which you need to delete after the DROP DATABASE keywords.

how to delete database in MySQL

how to delete a database in MySQL Linux

  1. Log into MySQL server using root user.
  2. Enter the root user password and press enter and do login.
  3. Now see all databases using the ‘show databases‘ command.
  4. Drop database using the ‘drop database‘ statement.

Be careful when you are going to delete your MySQL database because dropping or deleting the database will result in losing all information stored in the database. Also, keep in mind that you have admin privileges, otherwise you can’t delete database.

Select database carfully for delete. Beacuse once it deleted you can’t roll back you need to restore it’s backup to recreate that backup. So datbase name should be unique in the MySQL server instance. It will make your drop datbase statment more easy. All mysql versions have same command for drop/delete database so you don’t need worry about drop database command. Beacuse it remains same for all mysql versions.

About Sameer

I'm Sameer Bille, a blogger from Mumbai, India. I started MuchTech as a passion.Here at Much Tech I write about Tech Tips,Tricks and how to guide.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.