Mongosh syntax to connect to Atlas Cluster

I’m trying to connect to my Cluster on Atlas by using mongosh.exe from Windows.
But I cannot find the right syntax.
I could import the Datasample people.json into my Cluster on Atlas by using mongoimport.exe from Windows.

Could you give me the syntax to use with mongosh.exe using URI ?


Hi Cyrille,

are you able to visit your Atlas cluster in your browser and find your way to the uploaded people collection? That would show us that your Atlas cluster is all well and healthy, up and running.

At your people connection you should be able to easily spot a CONNECT button (should be visible without further clicks) which leads you to a so called connection string (like mongo-srv:// which gives you one way (of several possible ways) to connect via Windows cmd.exe terminal.

Can you find the CONNECT button? Does the connection string help?

Regards. M.

You are suppose to use mongo not mongosh
The course is designed to work with legacy mongo
For connect string follow Uwe_Scheffer reply

Hello Uwe,

Yes, I can the the two collections that I have imported with mongoimport from Windows cmd terminal in Atlas.
I used those commands using the URI given by the CONNECT button in Atlas

./mongoimport --drop -c people --uri mongodb+srv://m201usr:m201usr@******** people.json
./mongoimport --drop -c restaurants --uri mongodb+srv://m201usr:°°°°°°°°° restaurants.json

Maybe, as Ramachandra suggested, I shouldn’t use mongosh but mongo ?

Hi @Cyrille_Carmier

The course is written to use the older Mongo Shell, mongo rather than the new version Mongosh. Please use the older version, you should connect using the mongo.exe shell.

The newer Mongosh shell is only in a Beta release and does not yet have the full functionality of the older shell. We do intend to migrate our courses to it, once it is at the generally available (GA) release.

Kindest regards,

1 Like

Hi Cyrille,

thank you for your response and your postings of used mongo shell commands for import and export.

It just happened that I finished M201 right this week, furthermore I did several other mongo university courses within recent weeks, so I could easily reconstruct your scenario with the m201 database and its people and restaurants collections.

I was able to do a successful mongoexport with both collections. I didn’t do any mongoimport because it was not necessary for proving anything. However, the successful mongoexport lead to some confidece in my mongo as well as mongosh login attempts into Atlas - which both succeeded at least using Linux.

So, here’s the syntax you asked for:

mongo "mongodb+srv://" --authenticationDatabase "admin"

In my case (a Linux box) I could replace mongo with mongosh and successfully connect, too.

By the way, though I have mongo as well as mongosh installed locally, both being fully functioning, I also recommend @brazileoin 's advice above that you mostly use mongo and not mongosh for the time being.

Maybe my “findings” offer an additional perspective and you can move forward with m201.

Regards, M.