“Invalid ns” when connecting to mongodb server

梦想的初衷 提交于 2019-12-11 08:21:28

问题


Im trying to connect to a MongoLabs mongodb server I setup for a small project Im working on. I can connect fine when connecting from my local machine, but when I try to make a connection from my Mediatemple server I get a 'Invalid ns' error:

Unable to connect to MongoDB: Failed to connect to: dsXXXXXX.mongolab.com:27769: send_package: the query returned a failure: Invalid ns [XXXXXX_dev/XXXXXX_dev.$cmd] (code: 16256)

Any suggestions on how to fix this would be a major help.


回答1:


Perhaps your database name in your connection string or collection name (together they make a namespace) have special characters, and they make the namespace name illegal.

So you should make sure your connection string is ok.

For example, mine looks like

mongodb://mydblogin:mydbpassword@ds044444.mongolab.com:44444/mydatabase

Also make sure that collection name is legal.



来源:https://stackoverflow.com/questions/21827892/invalid-ns-when-connecting-to-mongodb-server

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