Create new database in mongoDB

You are here : Home / MongoDB Tutorial



Contents of page >


1) Create new database in mongoDB>


Once you are connected to mongoDB


MongoDB shell version: 3.0.6
connecting to: test     (Now, you are CONNECTED)
> use mydb
switched to db mydb
>


We created new database(if not exists) in mongoDB named mydb


2) See list of all databases in MongoDb>
> show dbs
admin   0.078GB
local   0.078GB
mydb    0.078GB
testdb  0.078GB
yourdb  0.078GB
>
You can see mydb which you have created.


3) You can switch any of above db by using command in MongoDb>
use testdb;    It will switch to testdb.  
> use testdb;
switched to db testdb
>



SUMMARY>
So in this mongoDB tutorial we learned how to
1) Create new database in mongoDB>
use mydb
2) See list of all databases in MongoDb>
show dbs
3) You can switch any of above db by using command in MongoDb>
use testdb;    It will switch to testdb.  


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.

RELATED LINKS>

What is MongoDB - A quick introduction to database



Difference in MongoDB and RDBMS - What are Database, collection, document and field in MongoDB



eEdit
Must read for you :