Not able to connect mongo shell or mongosh with atlas database,

I am trying from many days to connect my mongo shell or mongosh with Atlas but its giving error all the time. I need it to complete lab test to continue my course. I am copying error messages below to have look.

mongo “mongodb+srv://cluster0-jxeqq.mongodb.net/test” --username m001-student -password m001-mongodb-basics
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6
mongo “mongodb+srv://sanbox.c8vqn.mongodb.net/Sanbox” --username m001-student
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6
mongo “mongodb+srv://sanbox.c8vqn.mongodb.net/Sanbox” --username m001-student-student -password m001-mongodb-basics
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6
mongo “mongodb+srv://sanbox.c8vqn.mongodb.net/Sanbox” --username m001-student --password m001-mongodb-basics
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6
mongo “mongodb+srv://sanbox.c8vqn.mongodb.net/Sanbox” --username m001-student–password m001-mongodb-basics
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6

Most likely you are already in the mongo shell.

You must exit the current shell and run the mongo command in the terminal.

1 Like

Thanks for your reply, I tried to exit from shell with “ctrl + C” and “ctrl + d” commands and tryed to run again code to connect with Atlas but no success. I am also trying to check momgodb version and its gave an error for that as well

> mongod --version
uncaught exception: SyntaxError: unexpected token: identifier :

and still when i tried to connect with Atlas I got rhis message.

> mongo “mongodb+srv://sanbox.c8vqn.mongodb.net/Sanbox” --username m001-student–password m001-mongodb-basics
uncaught exception: SyntaxError: unexpected token: string literal :
@(shell):1:6

You are still at mongo shell
(">") indicates mongo shell

exit or quit() then run the command from your os prompt ($ or # etc)

3 Likes

It’s worked. thank you for suggestion.

1 Like