DbSchema | MySQL - How to Drop a Database?
In MySQL, databases are used to store collections of tables. If you no longer need a database, you can delete it. In this article, we will learn how to delete a database in MySQL.
Prerequisites
Before we begin, you should have the following:
- Administrative privileges to delete databases
Deleting a Database
To delete a database in MySQL, follow these
steps:
- Open the MySQL client.
- Log in to the MySQL server using the following command:
mysql -u username -p
Replace __username` with your MySQL username. You will be prompted to enter your password.
- Once you are logged in, use the following command to delete the database:
DROP DATABASE dbname;
Replace __dbname` with the name of the database you want to delete.
- Verify that the database has been deleted by using the following command:
SHOW DATABASES;
This will display a list of all the databases on the MySQL server, excluding the one you just deleted.
Warning: Be careful when using the __DROP DATABASE` command as it permanently deletes the database and all its tables and data.
Drop Database and Visually Manage MySql using DbSchema
DbSchema is a MySQL client and visual designer. DbSchema has a free Community Edition, which can be downloaded here.
Drop Database
Open an SQL Editor in DbSchema, type and execute the drop database command
Conclusion
Deleting a database in MySQL is a simple process. You just need to log in to the MySQL server and use the __DROP DATABASE` command to delete the database. Remember to use this command with caution as it permanently deletes the database and all its data.