gpt4 book ai didi

node.js - Mongo Atlas : Connection authentication failed with custom databases

转载 作者:IT老高 更新时间:2023-10-28 23:22:59 25 4
gpt4 key购买 nike

我正在尝试 Mongo Atlas Cloud。我创建了一个集群,并尝试与 mongo shell 建立连接:(与 mongo 驱动程序相同)

mongo mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=****-Cluster-shard-0 --ssl --username ***** --password *****

这是文档中的连接字符串。这是错误:

MongoDB shell version: 3.2.7
connecting to: mongodb://***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017/any_database?replicaSet=***-Cluster-shard-0
2016-07-07T01:31:17.535-0300 I NETWORK [thread1] Starting new replica set monitor for ***-Cluster-shard-0/***-cluster-shard-00-00-***.mongodb.net:27017,***-cluster-shard-00-01-***.mongodb.net:27017,***-cluster-shard-00-02-***.mongodb.net:27017
2016-07-07T01:31:17.535-0300 I NETWORK [ReplicaSetMonitorWatcher] starting
2016-07-07T01:31:20.084-0300 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1441:20
@(auth):6:1
@(auth):1:2

exception: login failed

只有当我使用 admin 数据库 "/admin?"时才能连接到数据库在连接字符串中。

问题:

我需要使用控制台或 mongo 驱动程序连接到自定义数据库。

PD:我用“***”保护我的数据

最佳答案

您使用 admin 数据库进行身份验证。从那里您可以切换数据库。

当使用 Mongo 驱动连接时,你的连接字符串需要添加授权源:

/any_database?authSource=admin&replicaSet=xyz

关于node.js - Mongo Atlas : Connection authentication failed with custom databases,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38237663/

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