mongoDB身份验证失败错误(使用mLab时)

时间:2018-12-08 10:08:37

标签: mongodb mlab

我正在使用express模块​​和node.js创建网站。 我使用mlab和mongodb创建数据库。 但我认为我应该继续使用新的数据库, 并且我删除了mlab中的旧数据库并创建了一个新数据库。

但是当我创建一个新的连接字符串时, 它不再工作了。

const connStr = 'mongodb://<dbusername>:<dbpassword>@ds129454.mlab.com:29454/compinfo?authSource=compinfoB&w=1';
mongoose.connect(connStr, {useMongoClient: true });
mongoose.connection.on('error', console.error);

我已经在mlab上添加了用户,但是存在错误。

MongoError: Authentication failed.
at Function.MongoError.create (C:\Users\john\competition_info\node_modules\mongodb-core\lib\error.js:31:11)
at C:\Users\john\competition_info\node_modules\mongodb-core\lib\topologies\server.js:754:66
at Callbacks.emit (C:\Users\john\competition_info\node_modules\mongodb-core\lib\topologies\server.js:95:3)
at Connection.messageHandler (C:\Users\john\competition_info\node_modules\mongodb-core\lib\topologies\server.js:243:23)
at Socket.<anonymous> (C:\Users\john\competition_info\node_modules\mongodb-core\lib\connection\connection.js:262:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:597:20)
name: 'MongoError',
message: 'Authentication failed.',
ok: 0,
errmsg: 'Authentication failed.',
code: 18,
codeName: 'AuthenticationFailed',
operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1544262796 },
'$clusterTime':
{ clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1544262796 },
signature: { hash: [Object], keyId: [Object] } } }

竞争信息是我服务的名称。 对不起,我英语不好 希望我得到一个有用的答案...请

0 个答案:

没有答案
相关问题