I am new to mongodb . i was following a tutorial . when i type db.zips.find() nothing shows up in mongoshell . even there is a data present . can someone help me to resolve this .
Are you sure there is data in the database? Could be you’re on the wrong database?
What tutorial were you following and where did you get up to?
I am following mongodb university tutotial . i was in a test database . i switched to training database . when i try to access data using db.zips.find() nothing shows in shell . when i view data in compass ,the collection is present
And the shell and compass are definitely connected to the same server instance?
can you help me what should i do to resolve this issue
How did you connect via the shell and how did you connect via compass? Can you show screenshots of your connections / queries being run.
What connection strings did you use? I’m not sure tutorial you were running so can’t comment on the steps taken. Can you link to the tutorial you were running?
I connected to both via connection string . i attached screenchot for your reference . i tried to access on both shell and compass.
Here is the tutorial link .
On the shell can you run the commands:
show dbs
and also
show collections
Can you show a screenshot of compass showing data?
Looks like you’re on different databases on both connections, on the shell you need to swap to the sample_training database as that’s what’s being used in your compass query:
use sample_training
Unlike some other databases you don’t get a warning if you swap to a database or use a collection that does not exist, but it will be created if you insert a document to a collection on a database that does not exist (yet).
There are some limits to this (or used to be) when dealing with clusters but for the samples and tutorials just take note of which database you’re using.
Now i can see data in shell . thank you so much . i was following tutorials where they just mentionend use training instead of sample_training. now i can see data in shell .
Excellent, glad you got it working!