如何设置 mlab 数据库连接 azure 的身份验证? 我使用 Nodejs 作为堆栈。 下面列出了我所做的事情:
- 将 mlab 数据库的应用程序设置设置为 MONGODB_URI,并使用 mongodb://user: [email protected] :66666/数据库名称
- 在 mlab 数据库上创建管理员用户
这是出现的错误,
MongoError: Authentication failed.
at Function.MongoError.create (D:\home\site\wwwroot\node_modules\mongodb-core\lib\error.js:31:11)
at D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\pool.js:497:72
at authenticateStragglers (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\pool.js:443:16)
at Connection.messageHandler (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\pool.js:477:5)
at Socket.<anonymous> (D:\home\site\wwwroot\node_modules\mongodb-core\lib\connection\connection.js:331: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)
这里的mongo认证错误到底是怎么回事? 因为我尝试从本地连接到这个远程数据库,并且连接没有问题。
谢谢。
最佳答案
我使用azure服务中的cosmosdb解决了这个问题。看来默认使用azure cosmosdb
?ssl=true&replicaSet=globaldb
我认为这就是他们想要的授权。不仅仅是db的用户和密码。
关于node.js - Azure部署Mongo错误: Authentication failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53039091/