node.js - ( Node :32032) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed

标签 node.js mongodb mongoose cloud9

我正在尝试从 mlabs 连接 mongodb。我插入了以下代码:

Mongoose.connect('mongodb://<dhan004>:<password1>@ds163402.mlab.com:63402/projecttwist', {useNewUrlParser: true }); 

然后它给了我这个错误:

(node:32032) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed.

谁能解释一下为什么我会收到此错误?

最佳答案

只需从用户名和密码部分删除括号(< 和 >)即可。

用户名应使用:dhan004

您应该使用的密码:password1

所以你的最终数据库地址应该是:

Mongoose.connect('mongodb://dhan004:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5121302222263e2335601135226067626561637f3c3d30337f323e3c" rel="noreferrer noopener nofollow">[email protected]</a>:63402/projecttwist', {useNewUrlParser: true });

关于node.js - ( Node :32032) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52417382/

相关文章:

mysql - Sequelize 模型中的自动填充字段?

node.js - 出现错误 : nodemon not found when running docker-compose

mongodb : could not find member to sync from

node.js - 我的本地主机登录页面上的POST请求给出了ERR_EMPTY_RESPONSE

javascript - 为什么 console.log() 显示一个数组,但 typeof 返回 'object' ?

javascript - 无法将嵌套对象传递给 res.render()?

javascript - WebStorm - 快速查找相关脚本

javascript - Mongoose 不返回记录

node.js - Mongoose 模型架构引用不起作用

javascript - Mongoose find() 不适用于 $not 查询