This demo will show you how to create database mongoDB . Please follow below steps:
- Install and start mongoDB using this tutorial URL: Install mongoDB
- Now go to mongoDB bin folder look for what are default database available. It shows only one default database name local:
- To create new database execute below command: use mongoTestDB (Note : database will not be created until you save some document in it.
- Confirm that your session has the mongoTestDB database as context, by checking the value of the db object, which returns the name of the current database, as follows:
- Until now, if you issue the show dbs operation again, it will not include the mongoTestDB database. mongoTestDB will not permanently create a database until you insert data into that database.
- Now insert document to create a database permanently
- . Use following command to insert data:
This will create database name mongoTestDB permanently.