English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this chapter, we will see how to use MongoDB commands to delete a database.
db.dropDatabase()The command is used to delete the existing MongoDB database.
dropDatabase()The basic syntax of the command is as follows-
db.dropDatabase()
This will delete the selected database. If you have not selected any database, it will delete the default "test" database.
First, use the command show dbs Check the list of available databases 。
>show dbs local 0.78125GB mydb 0.23012GB test 0.23012GB >
If you want to delete a new database<mydb>,then use dropDatabase()Command as follows:
>use mydb switched to db mydb >db.dropDatabase() { "dropped" : "mydb", "ok" : 1 } >
Now check the list of databases.
>show dbs local 0.78125GB test 0.23012GB >