我正在尝试从 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/