Follow by Email

MongoDB - Drop database

The dropDatabase command is used to delete a database. It also deletes the associated data files from the mongodb data folder.
This syntax will delete the selected database. In the case you have not selected any database, it will delete default "test" database.

To check the database list, use the command show databases:
>show databases  
mongotutors 0.078GB
local 0.078GB

To delete the database "mongotutors", first switch to database “Mongotutors” and then use the dropDatabase() command as follows:
>use mongotutors
{“dropped": "mongotutors", "ok": 1}

To verify if the database is deleted or not, check the list of databases:
>show databases  
local 0.078GB