To show all the databases present in MongoDB, you need to issue the "show dbs" command at the prompt:
MongoDB shell version: 2.6.5
connecting to: test
> show dbs
admin 0.078GB
local 0.078GB
Only two databases exist i.e. the system dbs 'admin' and 'local'
Next, issue the command "use new-db" to switch from the default database to the defined database "new-db". At this juncture, MongoDB will not automatically create any databases or collections yet until you manually create a collection or save a document inside. So run the following commands
> use new-db
switched to db new-db
> show dbs
admin 0.078GB
local 0.078GB
"new-db" does not show up after the "show dbs" command because it does not have any collections yet, so you need to create a test collection named "people", and insert a document inside. There are a couple of ways you can go about creating a collection, you can either issue the db.createCollection() command:
The following command simply creates a collection named people:
> db.createCollection("people")
Or you can just call the collection's insert() or save() command, which will automatically create the collection and the new-db database:
> db.people.save({"name": "mujaffars"})
WriteResult({ "nInserted" : 1 })
> db.people.find()
{ "_id" : ObjectId("5627430e0899b9f16b9bd781"), "name" : "mujaffars" }
> show dbs
admin 0.078GB
local 0.078GB
new-db 0.078GB