简体   繁体   English

将mongo db连接到远程服务器nodejs

[英]Connect mongo db to remote server nodejs

I nave nodejs server and connecting to Mongo DB locally using mongoose as: 我使用mongoose在本地连接nodejs服务器并连接到Mongo DB:

mongooseQ.connect("mongodb://localhost:27017/YepiMobile"); 

How can I connect to mongo db that locating on remote server from my machine? 如何从我的机器连接到位于远程服务器上的mongo db?

Something like: 就像是:

mongooseQ.connect("mongodb://remote.server.com:27017/YepiMobile"); 

Does the second connection attempt fail for you, by reading Mongoose's documentation it seems like you have done it correctly: 第二次连接尝试是否失败,通过阅读Mongoose的文档,您似乎已经正确地完成了它:

mongoose.connect('mongodb://username:password@host:port/database?options...');

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/ . 有关更多信息,请参阅此链接: http//mongoosejs.com/docs/connections.html ,或参阅MongoDB的连接文档: http//docs.mongodb.org/manual/reference/connection-string/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM