0

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.

Lost
  • 12,007
  • 32
  • 121
  • 193

2 Answers2

2

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
JohnnyHK
  • 305,182
  • 66
  • 621
  • 471
  • Ok I did var `somedb = connect('someserver/somedb');` and it says connecting to someserver but after that if I do show dbs then it shows me dbs from localhost – Lost Sep 18 '12 at 23:24
  • I tried ./mongo someserver/somedb and it throws syntax error :1 – Lost Sep 18 '12 at 23:27
  • 1
    @Californicated Right, `somedb` then becomes your access to the `somedb` database on `someserver`. So you can query it as `somedb.foo.find()`. Don't execute `mongo someserver/somedb` within the mongo shell, execute that back out at the command prompt. – JohnnyHK Sep 19 '12 at 00:17
0

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.

Landon
  • 4,088
  • 3
  • 28
  • 42
  • Service is up. I can connect to is using MongoVue and access all the Dbs under it very fine. – Lost Sep 18 '12 at 23:35