简体   繁体   English

NodeJS MongoDB连接字符串问题

[英]NodeJS MongoDB Connection string problems

I'm new to using MongoDB and would appreciate some help in replicating the following command in my NodeJS application. 我是MongoDB的新手,希望能在我的NodeJS应用程序中复制以下命令时提供一些帮助。

mongo --host dds-xxxx.mongodb.rds.aliyuncs.com:3717 -u root -p password --authenticationDatabase admin

I need to be able to connect with these credentials from Node, preferably but not necessarily using the MongoJS library. 我需要能够与Node的这些凭证连接,最好但不一定是使用MongoJS库。 Any assistance would be greatly appreciated! 任何帮助将不胜感激!

Thanks again. 再次感谢。

You can use the following: 您可以使用以下内容:

mongoose.connect('mongodb://username:password@host:port/database

In your case: 在您的情况下:

 mongoose.connect('mongodb://root:password@dds-xxxx.mongodb.rds.aliyuncs.com:3717/admin

You can find more at: http://mongoosejs.com/docs/connections.html 您可以在以下位置找到更多信息: http : //mongoosejs.com/docs/connections.html

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

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