Connecting to Our Class Atlas Cluster from the mongo Shell

I am trying to connect Atlas Cluster through Shell (cmd)
I have used them, the given command to connect to the cluster. I have edited by replacing 100YWeatherSmall instead of test. but always get an error like
‘’ SyntaxError: missing ; before statement @(shell):1:6
I tied to replace test with ‘100YearWeatherSmall’ but the same error.

can someone let me know an exact command to connect to Atlas Cluster from (cmd) Mongo Shell

Hi smlokhande,

Its difficult to replicate the same syntax error, please share the exact command you are using.

  • You are using wrong database name.

It is 100YWeatherSmall.

  • And here is the command that I used to connect:

      mongo "mongodb://,," --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Let me know.


You cannot run that inside the mongo shell, that’s a Linux command.

Hi Kanika,
Thanks for you replay . I am using ‘100YWeatherSmall’ Databse name but not connecting. it shows three dots and that it

mongo “mongodb://,,” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Thanks for reply I am using
mongo “mongodb://,,” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

What comand I should try on windows cmd?

I should have been more precise… “mongod” is an OS command (Linux or Windows). You are running it inside the Mongo shell, instead of the OS shell. That does NOT work. You run your mongod command from the Windows prompt.

Hi smlokhande,

Thanks @Tess_Sluijter, I should have been more careful.

@smlokhande, There are few things that you are missing here on the basics. With these you are all set:

  • OS Shell: If you want to connect to Atlas cluster from your OS shell, then you don’t need to start mongod process as Atlas is already doing that for you.
    You just need a command to connect to your atlas cluster.
  • To do that, instead of using mongo --nodb, just run the command from your OS shell and you will be connected to the Mongo shell.

        mongo "mongodb://,," --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

And just to make things clear for you:

  • Mongo Shell: If you are already in the mongo shell, then to switch to another database, you use the below command:

     use 100YWeatherSmall

Note: You cannot change the database if you started the Mongo shell with --nodb option. As this option prevents the shell from connecting to any database instances. To connect with the database from the same Mongo shell, look here. Best and easy way would be to disconnect and connect with appropriate connection parameters.



I have to solve and submit chapter2 Lab assignment. But i can’t choose an answer, look like it’s desirable . How should I complete assignmnet before Dec 18 ?

Wasn’t chapter 2 last week’s assignment? If so, then your deadline has passed and you can no longer submit the lab results. You should be able to see this in the left menu bar when you’re in the lab assignment. It should show a deadline. It will show the deadline at the top-right of the assignment as well.

Im getting some error too,

May be some junk character while pasting command

Try again

vagrant@m103:/shared$ mongo “mongodb://,,” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
MongoDB shell version v3.6.9
connecting to: mongodb://,,

pen to with a 5 second timeout)
Implicit session: session { “id” : UUID(“9109a90c-b500-455c-8ac9-fb43ebd73d58”) }
MongoDB server version: 3.6.10
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

Nope :slight_smile:

Like so many others they are running the “mongo” command inside the mongo shell, which cannot work.

@Tyn_06328: DO NOT first start a mongo shell. The long Mongo connection command should be run from the OS shell. If you had searched these forums for the error message, you would have found the answer quite a few times :slight_smile:

got it, maybe there’s an invalid character included on my script.

mongo “mongodb://,,” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

this one seems to work. Thank you

Thanks Tess
I assumed they are connecting from OS prompt
This is a frequently reported error(issuing mongo while connected to mongo shell)

Correct, which is exactly why I already made a “sticky” thread with the most common mistakes.