Mongodb:SyntaxError: Unexpected identifier
Asked Answered
C

3

5

i am new in mongodb. i am creating free database using mongolab. my database name is enron. connecting to mongo database using online mongoshell then error occure.

  mongo ds033499.mongolab.com:33499/enron -u user -p user123

error

  SyntaxError: Unexpected identifier
Call answered 7/3, 2014 at 7:16 Comment(8)
your syntax seems to be ok, what online mongoshell you are using?? this syntax works perfectly from linux machine shell.Instant
i am using try.mongodb.org this shell.i am also install mongodb on widows machine.my machine shell also same error occureCall
@AdeelAhmad no the syntax is not okay it's missing the host option ie mongo -h ds033499.mongolab.com:33499/enronHyacinthie
used mongo -h ds033499.mongolab.com:33499/enron but same error occureCall
@neil: this syntax is mentioned in mongolab. its correct :-) and the shell he is using is mongo shell. i am not sure if we can connect to remote mongo instance from mongo shell.Instant
@AdeelAhmad Read the line. There is no -h parameter for the host, which is remote. The main problem was trying to use the "try" shell as a shell. But also this question is off-topic and belongs on another stack exchange site such as super userHyacinthie
@AdeelAhmad i have install mongodb on my windows machine.but it is possible to connect to remote database using my machine mongo shellCall
sorry may be you get me wrong, yes its possible to connect to mongo remote instance using mongo shell but not when you are inside mongo shell that was my point. may be paramod didn't install mongo administrative shell on his windows machine.Instant
H
4

I had this problem and found that mongod.exe was interfering and wouldn't let me connect remotely. Without mongod.exe running, the mongo.exe wouldn't open from windows, so you have to goto the mongo/bin directory in the cmd prompt and THEN run your remote connection syntax there and it will work.

Hypognathous answered 8/4, 2014 at 18:26 Comment(0)
I
5

Your Syntax is OK. this syntax is for linux shell and didn't work when you are inside mongo shell. you can not connect to remote mongo instance when you are inside mongo shell. perhaps you are trying online shell like this and it is just as you are inside mongoshell:

http://try.mongodb.org/ 

you can connect to instance using linux shell with same syntax, or if you are a windows users you must have mongo administrative shell installed on you windows machines which comes with mongo setup for windows. or you can use GUI tool like Robomongo or Mongo VUE just to access mongo instance.

Or in Windows go to your mongo bin directory and type > mongo.exe --host ipofremote --port 27017

Instant answered 7/3, 2014 at 7:36 Comment(4)
i am using windows machineCall
if you are a windows users, you can use utility likes Robomongo, Mongo VUE to access remote instance. i preferred Robomongo it has many useful features.Instant
if you want to use mongo shell on windows, you need to install it first.Instant
yes i have install monogodb on my machine. then same command used or not?Call
H
4

I had this problem and found that mongod.exe was interfering and wouldn't let me connect remotely. Without mongod.exe running, the mongo.exe wouldn't open from windows, so you have to goto the mongo/bin directory in the cmd prompt and THEN run your remote connection syntax there and it will work.

Hypognathous answered 8/4, 2014 at 18:26 Comment(0)
C
0

Please try the following command

mongo -u admin -p tQp93-a29J --host servicedelivered.rhcloud.com --port 28015 --nodb

so now you are connecting to the remote host and switch to the database that you would like to use

Chapland answered 20/9, 2015 at 2:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.