gpt4 book ai didi

node.js - 在连接字符串中使用数据库名称时出现 Mongoose 连接错误

转载 作者:行者123 更新时间:2023-12-04 12:37:40 24 4
gpt4 key购买 nike

当我尝试使用此连接字符串连接到 Mongo 实例时mongodb://root:password@localhost:27017/但是,当我尝试在连接字符串中指定数据库名称时,一切正常
IE mongodb://root:password@localhost:27017/storefont我收到以下错误 MongoDB 连接错误:MongoNetworkError:首次连接时无法连接到服务器 [localhost:27017] [MongoError:身份验证失败。

最佳答案

像这样指定身份验证数据库:

mongodb://root:password@localhost:27017/storefont?authSource=admin
如果您指定一个数据库,则默认情况下也会使用该数据库进行身份验证。 MongoDB 文档在该主题中不是 100% 清楚。
另见 Authentication failure while trying to save to mongodb

关于node.js - 在连接字符串中使用数据库名称时出现 Mongoose 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62818786/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com