### 13.1.24 DROP DATABASE Statement

[]()[]()[]()[]()[]()[]()

```
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
```

[`DROP DATABASE`](drop-database.html) drops all tables in the database and deletes the database. Be *very* careful with this statement! To use [`DROP DATABASE`](drop-database.html), you need the [`DROP`](privileges-provided.html#priv_drop) privilege on the database. [`DROP SCHEMA`](drop-database.html) is a synonym for [`DROP DATABASE`](drop-database.html).

Important

 When a database is dropped, privileges granted specifically for the database are *not* automatically dropped. They must be dropped manually. See [Section 13.7.1.6, “GRANT Statement”](grant.html).

`IF EXISTS` is used to prevent an error from occurring if the database does not exist.

 If the default database is dropped, the default database is unset (the [`DATABASE()`](information-functions.html#function_database) function returns `NULL`).

 If you use [`DROP DATABASE`](drop-database.html) on a symbolically linked database, both the link and the original database are deleted.

[`DROP DATABASE`](drop-database.html) returns the number of tables that were removed.

 The [`DROP DATABASE`](drop-database.html) statement removes from the given database directory those files and directories that MySQL itself may create during normal operation. This includes all files with the extensions shown in the following list:

* `.BAK`

* `.DAT`

* `.HSH`

* `.MRG`

* `.MYD`

* `.MYI`

* `.cfg`

* `.db`

* `.ibd`

* `.ndb`

 If other files or directories remain in the database directory after MySQL removes those just listed, the database directory cannot be removed. In this case, you must remove any remaining files or directories manually and issue the [`DROP DATABASE`](drop-database.html) statement again.

 Dropping a database does not remove any `TEMPORARY` tables that were created in that database. `TEMPORARY` tables are automatically removed when the session that created them ends. See [Section 13.1.20.2, “CREATE TEMPORARY TABLE Statement”](create-temporary-table.html).

[]()

 You can also drop databases with [**mysqladmin**](mysqladmin.html). See [Section 4.5.2, “mysqladmin — A MySQL Server Administration Program”](mysqladmin.html).

