How to Create a MongoDB Database Using Mongo Shell
To create a new MongoDB database using Mongo Shell use the “use Database_Name” command. This command creates a new database if it doesn’t exist, otherwise, it will return the existing database.
The newly created database will not be present in the list of databases. To display the database in the database list, insert at least one document into it.
Syntax
use Database_Name
Create a New Database Using Mongo Shell Example
The below image shows new database creation using Mongo Shell:
In MongoDB default database is test. If you did not create any Database and started inserting collection then all collections are stored in the Default Database.
MongoDB – Create Database using Mongo Shell
A MongoDB Database is the container for all the collections, where the Collection is a bunch of MongoDB documents similar to tables in RDBMS and the Document is made up of fields similar to a tuple in RDBMS, but it has a dynamic schema here.
This article explains the easy method to create a Database in MongoDB using Mongo Shell.
Contact Us