Error while connecting to cluster

In tried connecting to Cluster using the below command
mongo “mongodb://sandbox-shard-00-00-tj5mw.mongodb.net:27017,sandbox-shard-00-01-tj5mw.mongodb.net:27017,sandbox-shard-00-02-tj5mw.mongodb.net:27017/test?replicaSet=Sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

but I ended up with the err message 2019-02-06T15:38:09.407+0530 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6.

So please let me know what I am missing here. Thanks

It says syntax error
Make sure no spaces or junk characters in your command while cut & paste

I am able to connect using the same command you are using. Make sure:

  • Double quotes are replaced on the terminal if you doing copy/paste. It should not be special characters,
  • You are not connecting from Mongo Shell. You have to type this command from your OS terminal/command line and not when you are in mongo shell.

Kanika

You might be already connected and executing this command. Check if you are inside MongoD shell . I had the exact same issue. The reason is when I first ran the command it displayed some warning about version mis-match. I thought it was not connected. But in reality it got connected already.I was trying to run this command when I was already shell. Check the shell prompt.

close the terminal window and reopen it. don’t do any other thing like mongo --db… just type in/copy the connection string to the shell only. it should work

Thanks it works. The command needs to be typed in command prompt not mongo shell. Plz update lecture notes with the common error people face.

Yes sure.

I will make sure I will add in the Lecture notes. :slight_smile:

Thanks for the feedback!!

Kanika