How Do I Delete a Database in Mongodb

Select the database you want to delete with the help of USE <database> command. Following is the syntax of USE command. use <database_name>Drop the database with the help of db.dropDatabase() command. Following is the syntax of USE command. db.dropDatabase()

Which of the following will delete current database in MongoDB?

MongoDB db. dropDatabase() command is used to drop a existing database.

How do I delete a collection in MongoDB?

Starting in MongoDB 5.0, the drop command and the db. collection. drop() method return an error if you try to drop a collection in the admin database or the config database from a mongos . To drop these collections, connect to the config server and run the command there.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest