Knowing how to drop a Database in MongoDB is essential for every developer. This tutorial shows you how to drop specified databases from the MongoDB server using different methods.
Drop Database in MongoDB
You can drop a database in MongoDB in two ways: first, using the MongoDB shell and second, using the MongoDB compass, a graphical user interface.
Drop Database in MongoDB Using Mongosh Shell
To drop the database, use the db.dropDatabase() command and open the Mongo shell by entering the “Mongosh” command.
mongosh
View all the databases.
show dbs
Then, switch to the database you want to drop; in my case, I will delete the database “library.”
use library
To drop the database, use the command below, which deletes the currently selected database.
db.dropDatabase()

After executing db.dropDatabase(), view all the databases again. You won’t see the “library” database because it has been deleted.
Drop Database in MongoDB Using Compass
The MongoDB compass is a graphical user interface for managing and manipulating data; you can use it to drop any database.
Open the MongoDB compass and go to the right section to view the entire database. Then, hover over the database you want to drop; a delete icon appears when you hover. To drop the database, click the delete icon in the picture below.

As soon as you click on the delete icon, a dialogue appears. In it, you need to confirm the deletion of the database by typing its name in the field. So, type the database name you want to drop, then click the Drop Database button.

After clicking the Drop Database button, the database named ‘library’ is dropped successfully; you won’t see it in the database section at the right side of your window.
Conclusion
Dropping the database base is usually done whenever it is no longer required; knowing how to drop a database in MongoDB is a must, so you learned how to drop a database using the MongoDB shell and Compass.
You may also like reading the following MongoDB tutorials.
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.