Trouble connecting to Mongo Server using Mongo Shell
-
02-07-2021 - |
Pergunta
I ampretty new to Mongo shell and I am trying to switch the server using shell. My current server is of course localhost. I am trying to connect to someserver and the command that I am using for this is basically
mongodb://someserver
I also tries
mongodb://someserver:27017
in both cases my command is followed by ... and then it does nothing. I am still on localhost.
Please note that there are no credential required on someserver.
Solução
You can't directly switch to a different connection from the mongo shell prompt. You can open additional connections though as:
var somedb = connect('someserver/somedb');
To start over with a new mongo server, at the command shell prompt:
mongo someserver/somedb
Outras dicas
Can you telnet to that host and port combo? When I have problems, that's the first thing I do to make sure I can see that service, at the very least.