Follow by Email

MongoDB - Create database

MongoDB “use DATABASE_NAME” is used to create database. The command will create a new database if it doesn't exist or it will switch to existing database.

Basic syntax of use DATABASE statement is as follows −
To switch
>use Testting
Your created database (Testting) is not present in list. To display database, you need to insert at least one document into it.
>db.tutorials.insert({"name":"MongoDB tutorials"})

Display all databases :
>show databases
Admin      0.000GB
Local      0.000GB
Testting   0.000GB

To show collections:
>show collections

Please check the below mongo shell commands and its respective output: