How to drop database in MongoDB

by Ismail.EL
0 comment

How to drop database in MongoDB

In this guide, i will show you how drop a database in MongoDB.

The dropDatabase() Method
MongoDB db.dropDatabase() command is used to drop a existing database.
Syntax:
Basic syntax of dropDatabase() command is as follows:

db.dropDatabase()

This will delete the selected database.

NB: If you have not selected any database, the “test” default database will be deleted.

1. check the list available databases:

Issue “show dbs” to display all available databases.

2. Drop a database (devops-teamDB):

If you want to delete database <devops-teamDB>, then devops-teamDB() command would be as follows:

switched to db devops-teamDB

Now check list of databases:

3. Conclusion

In this post, i have explained How to drop database in MongoDB.
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂

21100cookie-checkHow to drop database in MongoDB

Related Posts

Leave a Comment