Mongodb:SyntaxError: Unexpected identifier

大憨熊 提交于 2019-12-04 07:05:51

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.

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

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!