The DROP DATABASE statement permanently deletes an entire database from the MySQL server — including every table, every row of data, and all other objects stored inside it. Once dropped, the database and all its contents are gone and cannot be recovered unless you have a backup.
DROP DATABASE is irreversible. Always double-check the database name before running this command, and make sure you have a backup if the data is important.
DROP DATABASE database_name;
Replace database_name with the exact name of the database you want to delete. MySQL will immediately remove the database and all its contents.
The following statement permanently deletes the database named school:
DROP DATABASE school;
If successful, MySQL responds with:
Query OK, 0 rows affected (0.02 sec)
The database school — along with every table and record inside it — is now completely removed from the server.
If you try to drop a database that does not exist, MySQL throws an error:
DROP DATABASE school;
-- ERROR 1008 (HY000): Can't drop database 'school'; database doesn't exist
To handle this gracefully — particularly in cleanup scripts — use the IF EXISTS option:
DROP DATABASE IF EXISTS school;
With IF EXISTS, MySQL will only drop the database if it actually exists. If it does not, MySQL issues a warning instead of an error, and the script continues running without interruption.
DROP DATABASE IF EXISTS in setup and teardown scripts. This way, your scripts are safe to run repeatedly, whether or not the database currently exists.
In MySQL, the words DATABASE and SCHEMA mean the same thing and can be used interchangeably. So the following two statements are completely identical:
DROP DATABASE school;
DROP SCHEMA school;
Both delete the same database. You will encounter SCHEMA terminology more often in MySQL Workbench and in database design contexts.
When you drop a database, MySQL removes everything inside it permanently:
SHOW DATABASES; to confirm the exact name, and export a backup using mysqldump just in case.
DROP DATABASE name; permanently deletes the database and all its contents.IF EXISTS to prevent errors when the database may not exist.DROP SCHEMA is an alias for DROP DATABASE — they do the same thing.