Create database in MongoDB

After installing the MongoDB, to use it, the first thing we need to know is: how we can create database in MongoDB. In this tutorial, I will show you how we can do that!

To create a new database in MongoDB, you will use the command as below:

This command will help us create a new database if it didn’t exist. In the case, there is a database with the same name with the database which we are creating, this command will return the existing database.

For example, I create a database, named mongodb using the MongoDB as below:

Create database in MongoDB


Add Comment