node.js - Azure 部署 MongoError:身份验证失败
问题描述
我们如何为 mlab 数据库设置身份验证以连接 azure?我使用 Nodejs 作为堆栈。在我所做的列表下方:
- 将 mlab 数据库的 App Setting 设置为 MONGODB_URI,并使用 mongodb://user:password@ds166666.mlab.com:66666/database-name
- 在 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 services 的 cosmosdb 解决了这个问题。似乎默认使用 azure cosmosdb
?ssl=true&replicaSet=globaldb
我认为这就是他们想要的那种授权。不仅仅是db的用户名和密码。
推荐阅读
- c# - 如何在列表中的最后一个负值之后获得正值?
- javascript - 名为“na......”的路线不存在。$router.push() 转到错误的路径 Vue Js
- c# - 找到未映射的成员( DateTime )
- google-apps-script - 使用带有静态 IP 谷歌脚本的 UrlFetch
- html - 尝试在响应的同时在每个旁边放置一个 iframe 和一个 div
- postgresql - 尽管一切似乎都正确,为什么这段代码给了我错误?
- python - 是否所有标准库 Python 接口都记录在一个地方?
- ssl - IBM Cloud - Cloud Foundry - 在 mybluemix.net 域中禁用 SSL 重新协商
- pandas - 如何替换值前向减-1?
- oracle - 使用 oracle 形式的条件逻辑计算字段