In previous tutorial, we known how to create a database in MongoDB. In this tutorial, we will figure out how we can delete a existing database MongoDB!
First of all, you must login into MongoDB and choose the database which we need to delete by following command:
1 |
mongo <database_will_be_selected> |
Example, here I need delete a database named books, I will login into MongoDB and choose the database books as below:
To check list of existing databases in MongoDB, you can use the command:
1 |
show dbs |
Now, to delete a database, we will use the command:
1 |
db.dropDatabase() |
Here, I delete the database books as below:
Verify again list of databases: