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

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

我正在尝试从 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:password1@ds163402.mlab.com:63402/projecttwist', {useNewUrlParser: true });