MongoDB Drop Database

The dropDatabase command drops the current database, deleting the associated data files.

The command has the following form:

{ dropDatabase: 1 }

This sentence structure will erase the chose database. For the situation you have not chose any database, it will erase default "test" database.

The mongo shell also provides the helper method db.dropDatabase().


The following example in the mongo shell uses the use <database> operation to switch the current database to the temp database and then uses the dropDatabase command to drop the temp database:

use temp
db.runCommand( { dropDatabase: 1 } )