MongoDB:无法连接到新的副本集主服务器 [英] MongoDB: Can't connect to new replica set master

查看:210
本文介绍了MongoDB:无法连接到新的副本集主服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试为我的Node.JS应用程序设置MongoDB.我运行以下命令:

Trying to set up MongoDB for my Node.JS application. I running this command:

mongo "mongodb+srv://cluster0-gjc2u.mongodb.net/test"  --username <myusername>

并且每次都得到这个响应.

And getting this response every single time.

MongoDB shell version v4.2.1
Enter password:
connecting to: mongodb://cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2019-12-07T12:14:39.630-0600 I  NETWORK  [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.630-0600 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-00-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.631-0600 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-01-gjc2u.mongodb.net:27017
2019-12-07T12:14:39.631-0600 I  CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:40.259-0600 I  NETWORK  [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Cluster0-shard-0 is Cluster0-shard-0/cluster0-shard-00-00-gjc2u.mongodb.net:27017,cluster0-shard-00-01-gjc2u.mongodb.net:27017,cluster0-shard-00-02-gjc2u.mongodb.net:27017
2019-12-07T12:14:40.799-0600 I  NETWORK  [js] Marking host cluster0-shard-00-00-gjc2u.mongodb.net:27017 as failed :: caused by :: Location40659: can't connect to new replica set master [cluster0-shard-00-00-gjc2u.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed.


*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.


2019-12-07T12:14:40.800-0600 E  QUERY    [js] Error: can't connect to new replica set master [cluster0-shard-00-00-gjc2u.mongodb.net:27017], err: AuthenticationFailed: bad auth Authentication failed. :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-12-07T12:14:40.803-0600 F  -        [main] exception: connect failed
2019-12-07T12:14:40.804-0600 E  -        [main] exiting with code 1

我已将我的IP地址列入白名单,并确保一切正常.是什么导致此问题,我该如何解决?为什么会出现此问题?

I have whitelisted my IP address and made sure everything is in order. What could be causing this problem and how could I fix it? Why would this problem be occurring?

推荐答案

我尝试过的是:

  1. 创建新用户
  2. 确保连接应用程序时mongoURI的用户名和密码与连接mongo shell时的用户名和密码相同.
  3. 在应用程序的命令行中运行连接字符串.

这篇关于MongoDB:无法连接到新的副本集主服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆