# How to remove databases with MongoDB Drop Database

You can use the [MongoDB](https://www.ionos.com/digitalguide/websites/web-development/mongodb-an-introduction-and-comparison-to-mysql/) Drop Database command to remove a selected database. To get an overview of your databases both before and after removal you can use the MongoDB command *show dbs*.

## What is the MongoDB drop database command?

Unlike [database management systems](https://www.ionos.com/digitalguide/hosting/technical-matters/database-management-systems-dbms/ "Database Management Systems (DBMS)") such as [MySQL](https://www.ionos.com/digitalguide/server/know-how/what-is-mysql/ "What is MySQL"), which follow a relational concept, MongoDB aims to be completely **scalable and flexible**. There is a wide range of [MongoDB commands](https://www.ionos.com/digitalguide/websites/web-development/mongodb-commands/ "MongoDB commands") available. Data is saved, collated in collections using [MongoDB Create Collection](https://www.ionos.com/digitalguide/websites/web-development/mongodb-create-collection/ "MongoDB Create Collection") and indexed automatically or manually by using [MongoDB Create Index](https://www.ionos.com/digitalguide/websites/web-development/mongodb-create-index/ "MongoDB Create Index"). On top of this, you can use [MongoDB Create Database](https://www.ionos.com/digitalguide/websites/web-development/mongodb-create-database/ "MongoDB Create Database") to create databases and subsequently manage them. But what happens if a database is old or **no longer needed**? You can use MongoDB Drop Database to remove it.

## What is the MongoDB Drop Database syntax?

The syntax for the command is very short and is as follows:

```none
db.dropDatabase()
```

You **do not** **need to write** the name of the database to be deleted **explicitly** in the command. This isn’t needed because the command is carried out within the database.

## How to use MongoDB Drop Database

If you want to use MongoDB Drop Database to remove a database, you need to follow four steps. Let’s say you want to remove a database that you no longer need called “client list”. You can do this as follows:

### Pull up your databases

The first step is to check which databases you have. This allows you to avoid any errors and gives you a good overview. You can do this with the command *show dbs*:

```none
>show dbs
admin 0.7278GB
local 0.5388GB
client list 0.6636GB
test 0.7624GB
>
```

By using the command, you can see that there is a database called “client list”.

### Open the correct database

Before using MongoDB Drop Database, it’s important that you **switch to the correct database first**, i.e., the one which you want to delete. The system will confirm that you are in the correct database. You can do this by using the command *use*:

```none
>use client list
switched to db client list
>
```

The system will confirm that you are in the correct database. Now you are in, you can carry out the MongoDB Drop Database command risk free. If you haven’t selected a database, the system will **remove a test database**. This isn’t a problem, but it also doesn’t offer you anything.

### Removal using MongoDB Drop Database

If you use drop database to remove a database, the system will confirm that it has been successful. It will look something like this:

```none
>use client list
switched to db client list
>db.dropDatabase()
>{ "dropped" : "client list", "ok" : 1 }
>
```

### Checking the removal

Double check your database directory again to be certain that the MongoDB Drop Database command was successful using the command *show dbs*. If it was successful, your directory will look as follows:

```none
>show dbs
admin 0.7278GB
local 0.5388GB
test 0.7624GB
>
```

Instead of the four databases shown previously, you have three remaining., meaning the removal was successful.


This is a markdown version of: [https://www.ionos.com/digitalguide/websites/web-development/mongodb-drop-database/](https://www.ionos.com/digitalguide/websites/web-development/mongodb-drop-database/) for AI/LLM consumption.