---
title: "How do you create a new database in MongoDB?"  
description: "How do you create a new database in MongoDB?"  
author: "Revati S Misra"  
published: 2023-05-16  
updated: 2023-05-18  
canonical: https://www.mindstick.com/forum/158365/how-do-you-create-a-new-database-in-mongodb  
category: "mongodb"  
tags: ["database", "mongodb", "database design"]  
reading_time: 2 minutes  

---

# How do you create a new database in MongoDB?

What are some [common](https://www.mindstick.com/articles/23170/10-most-common-accounting-mistakes-of-small-business) use cases for [MongoDB](https://www.mindstick.com/articles/337565/understanding-document-stores-a-look-at-mongodb-vs-couchdb) and how can it be used in a real-[world](https://yourviews.mindstick.com/view/87468/defining-humanity-as-given-in-sanatan-dharma-best-in-world) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android)?

## Replies

### Reply by Aryan Kumar

There are two ways to create a new database in MongoDB:

- **Using the MongoDB shell:** The MongoDB shell is a powerful tool that can be used to interact with a MongoDB database. To create a new database using the MongoDB shell, use the following command:

Code snippet

```plaintext
use <database_name>
```

where:

- <database_name> is the name of the database to create.

For example, the following command creates a database named my_database:

Code snippet

```plaintext
use my_database
```

- **Using the MongoDB driver:** The MongoDB driver is a library that can be used to interact with a MongoDB database from a variety of programming languages. To create a new database using the MongoDB driver, use the following method:

Code snippet

```plaintext
db.createDatabase( <database_name> )
```

where:

- <database_name> is the name of the database to create.

For example, the following code creates a database named my_database using the Python MongoDB driver:

Code snippet

```plaintext
from pymongo import MongoClient

client = MongoClient()
db = client.my_database
```

Once a database is created, you can create collections in it, insert documents into the collections, and query the documents.


---

Original Source: https://www.mindstick.com/forum/158365/how-do-you-create-a-new-database-in-mongodb

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
