MySQL DROP DATABASE Guide with Safety Checklist
For someone with administrative rights on a MySQL server who has to remove a database and wants the removal verified afterwards.
On this page
DROP DATABASE in MySQL: The Short Answer
If you no longer need a database and its data, you can completely delete it. In MySQL, you delete a database using the DROP DATABASE statement. This command drops the schema and permanently removes all the tables and data within it.
Prerequisites and Required Privileges
Before you can execute the drop command, your MySQL user account must have the correct permissions:
- The DROP privilege for the target database, or global DROP privileges.
DROP DATABASE Syntax
The MySQL reference manual gives the full form:
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name;
Drop a Database from the MySQL Client
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.
Using DROP DATABASE IF EXISTS
If you try to drop a database that is not on the server, MySQL throws an error. To prevent this, especially when writing automated setup or cleanup scripts, use the IF EXISTS clause. This tells MySQL to silently ignore the command if the database is already missing, issuing a warning instead of halting your script.
'Delete a Database' vs DROP DATABASE
Many users search for how to "delete a database", but MySQL does not have a DELETE DATABASE command. In SQL, the DELETE statement is exclusively used to remove individual rows from a table. To remove structural elements like databases, tables, or views, you must use data definition language (DDL) statements like DROP.
Safety Checklist Before You Drop
- Verify the connection: Run SELECT DATABASE(); or check your host string to ensure you are connected to the correct server (e.g., development vs. production).
- Take a backup: Use mysqldump to export the database. It is easier to delete the backup file later than to recreate lost data.
- Check dependent applications: Ensure no active services or applications rely on the database. Dropping it will instantly break those connections.
- Review replication: If your server is part of a replication setup, dropping the database on the primary server will also drop it on the replicas.
What Happens to Tables, Users and Grants
Executing DROP DATABASE physically deletes the directory representing the database and removes all tables and data within it. However, it does not automatically delete the users who had access to it, nor does it revoke their privileges. Because user grants are stored globally in the mysql.db system table, if you later create a new database with the exact same name, the old users will automatically regain their previous access.
Common Errors and How to Resolve Them
- Error 1008 (HY000): Can't drop database; database doesn't exist: You typed the wrong name or it has already been deleted. Use SHOW DATABASES; to check current names, or add IF EXISTS.
- Error 1044 (42000): Access denied for user: Your account does not have the DROP privilege. Contact your database administrator to grant the necessary permissions.
- Error 1010 (HY000): Error dropping database (can't rmdir): MySQL could not delete the database directory because it contains files not managed by MySQL (like custom logs or manual backups). You must remove those extra files from the data directory manually before the drop can complete.
Drop a Database Visually in 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.
See the database before you drop it
DbSchema connects to MySQL, reverse-engineers the schema into an ER diagram, and runs your DROP statement from the SQL Editor with a history of everything you executed. The Community Edition is free.

