Unable to connect to sandbox, via shell

It seems i am already connected to my local server, and I cant stablish a new connection. I keep getting syntax error Unexpected Token.
When I show dbs, i see my local server. From what I was able to find, I am getting this error because i already have a connection, but I could be wrong (Mongo is a new territory). How can I terminate my current connection and stablish a new one? using Shell.

Using the command exit.

This command closes the shell but when I reopen, it automatically connects to my local server.

You have to specify the connection string of your Atlas cluster as the first argument of the command mongo.

I am sure, my issue is very silly., i just cant seem to see it. I have un-installed my version of mongodb and downloaded a newer version. I am able to connect using Compass. But when i have tried to connect using the shell, i just get … . When i enter db it says i am in test, if i ask show dbs I get admin, local and config.
I tried with mongo and mogosh at the start of my connection string mongodb+srv://user:password@severInfo/myFirstDatabase

  • I am using mongodb shell version 5.0.3, I downloaded the mongodb community version
  • My IP is whitelisted, in my atlas security network access,
  • The password for my admin has no special characters.
  • Deactivated all firewalls / windows defender firewall

Post a screenshot of what you do that shows the issue you are having.

I also tried mongosh, adding the database I want it to connect to. I feel i am missing something.

As already mentioned:

And then

But it looks like you type the command mongo without argument first and then try to run the command mongo inside the mongo shell.

The exact string that you typed in the shell that looks like mongo mongodb+srv://… is the command you have to type after you exit the current mongo shell. So just to make sure when you are at the Windows terminal prompt you do not type mongo and the press ENTER. You type mongo mongodb+srv://… and the press ENTER. You might need to but the URI between single quotes.

Thank you so much for your help and patience. I am now able to connect. :grinning_face_with_smiling_eyes:

1 Like