This version will reach end of life on Feb 2018. To upgrade, go to the Learn more about upgrading your version of MongoDB.


On this page



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

The command has the following form:

{ dropDatabase: 1 }

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



This command obtains a global write lock and will block other operations until it has completed.

Changed in version 2.6: This command does not delete the users associated with the current database. To drop the associated users, run the dropAllUsersFromDatabase command in the database you are deleting.


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 } )
←   copydb listCollections  →