Question

I started mongodb by the command

mongod --dbpath ./data/

My app is able to save and retrieve data from the mongodb with the above server but when I go to mongo console from other terinal tab using

$ mongo 
MongoDB shell version: 2.6.0
connecting to: test
> show collections
> 

it doesn't show any collections. Is the mongodb connecting to another database? How do I connect to my db

Was it helpful?

Solution

Use the command:

use <database name>

where you replace <database name> with the name of your database that you want to connect to

OTHER TIPS

You may use the following command to show all databases:

show dbs
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top