On this page



Removes the current database, deleting the associated data files.


The db.dropDatabase() wraps the dropDatabase command. To specify a write concern, use the dropDatabase command.


Starting in versions 3.6, the operation takes an exclusive (X) database lock while dropping the collections in the database but a global lock when dropping the now-empty database.

User Management

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.

Replica Set and Sharded Clusters

Replica Sets

At minimum, the method waits until all collection drops in the database have propagated to a majority of the replica set members (i.e. uses the write concern "majority").

To specify a write concern greater than the minimum write concern of "majority", use the dropDatabase command.

Sharded Clusters

When issued on a sharded cluster, MongoDB converts the write concern of the dropDatabase command to "majority".


If you drop a database and create a new database with the same name, you must either restart all mongos instances, or use the flushRouterConfig command on all mongos instances before reading or writing to that database. This action ensures that the mongos instances refresh their metadata cache, including the location of the primary shard for the new database. Otherwise, the mongos may miss data on reads and may write data to a wrong shard.

Change Streams

The db.dropDatabase() method and dropDatabase command create an invalidate Event for any Change Streams opened on the dropped database or opened on the collections in the dropped database.


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 db.dropDatabase() method to drops the temp database:

use temp

See also


←   db.currentOp() db.eval()  →