/    /  MongoDB – Drop Database

MongoDB – Drop Database:

We can drop a database in mongoDB along with the associated datafiles.

syntax: db.dropDatabase()

But this will not delete the associate users in that database in version 2.6. To drop those users, we need to use dropAllUsersFromDatabase command.

Check the database you want to delete.

testset:PRIMARY>db imongo

Switch to database “imongo” before you drop the database.

testset:PRIMARY> use imongo
switched to dbimongo
{ "dropped" : "imongo", "ok" : 1 }

Verify if the database is existing by using the command show dbs.

testset:PRIMARY> show dbs
admin  0.031GB
local  1.577GB