O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dropping a Database

Use the DROP DATABASE command to drop a database completely. Use this command with extreme caution—you cannot recover a dropped database unless you have a backup.

Dropping Databases

A user must have the DROP privilege in order to drop a database. Grant this privilege sparingly.

To drop the greekdb database, issue the following command:

mysql> DROP DATABASE greekdb;
Query OK, 0 rows affected (0.00 sec)

Similar to CREATE DATABASE IF NOT EXISTS, you can use DROP DATABASE IF EXISTS to suppress an error if you try to drop a nonexistent database.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required