问题描述
我中止了nodejs服务器,并使用mongoose将本地连接到Mongo DB:
I nave nodejs server and connecting to Mongo DB locally using mongoose as:
mongooseQ.connect("mongodb://localhost:27017/YepiMobile");
如何从我的机器连接到位于远程服务器上的mongo db?
How can I connect to mongo db that locating on remote server from my machine?
类似的东西:
mongooseQ.connect("mongodb://remote.server.com:27017/YepiMobile");
推荐答案
通过阅读Mongoose的文档,第二次连接尝试是否为您失败?
Does the second connection attempt fail for you, by reading Mongoose's documentation it seems like you have done it correctly:
mongoose.connect('mongodb://username:password@host:port/database?options...');
也许您缺少服务器的凭据?有关更多信息,请参见此链接: http://mongoosejs.com/docs/connections.html ,或参阅MongoDB的连接文档: http://docs.mongodb.org/manual/reference/连接字符串/.
Maybe you are missing the credentials to the server? See this link for more information: http://mongoosejs.com/docs/connections.html, or see MongoDB's connection documentation: http://docs.mongodb.org/manual/reference/connection-string/.
这篇关于将mongo db连接到远程服务器Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!