我在MongoDB Atlas上设置了一个集群,让自己成为了管理员,但是我无法从shell连接到集群。在Atlas上,我点击了连接按钮,点击了与Mongo Shell的连接,下载了最新的Mongo Shell,并复制了命令以连接到集群:
mongo "mongodb://testcluster-shard-00-00-acqhf.mongodb.net:27017,testcluster-shard-00-01-acqhf.mongodb.net:27017,testcluster-shard-00-02-acqhf.mongodb.net:27017/test?replicaSet=TestCluster-shard-0" --authenticationDatabase admin --ssl --username <USERNAME> --password <PASSWORD>
当我运行此命令时,我得到了流:
MongoDB shell version v3.4.10
connecting to: mongodb://testcluster-shard-00-00-
acqhf.mongodb.net:27017,testcluster-shard-00-01-
acqhf.mongodb.net:27017,testcluster-shard-00-02-
acqhf.mongodb.net:27017/test?replicaSet=TestCluster-shard-0
2017-11-20T11:58:31.883-0500 I NETWORK [thread1] Starting new replica set monitor for TestCluster-shard-0/testcluster-shard-00-00-
acqhf.mongodb.net:27017,testcluster-shard-00-01-
acqhf.mongodb.net:27017,testcluster-shard-00-02-acqhf.mongodb.net:27017
2017-11-20T11:58:32.119-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-01-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-01-acqhf.mongodb.net:27017 with a 5 second timeout)
2017-11-20T11:58:32.131-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to testcluster-shard-00-00-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-00-acqhf.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 3.4.10
2017-11-20T11:58:32.407-0500 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to testcluster-shard-00-02-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-02-acqhf.mongodb.net:27017 with a 5 second timeout)
2017-11-20T11:58:32.497-0500 I NETWORK [thread1] Marking host testcluster-shard-00-01-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-01-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:32.639-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-02-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-02-acqhf.mongodb.net:27017 with a 0 second timeout)
2017-11-20T11:58:32.756-0500 I NETWORK [thread1] Marking host testcluster-shard-00-02-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-02-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:32.899-0500 I NETWORK [thread1] Successfully connected to testcluster-shard-00-00-acqhf.mongodb.net:27017 (1 connections now open to testcluster-shard-00-00-acqhf.mongodb.net:27017 with a 0 second timeout)
2017-11-20T11:58:32.995-0500 I NETWORK [thread1] Marking host testcluster-shard-00-00-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-00-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:33.100-0500 I NETWORK [thread1] Marking host testcluster-shard-00-01-acqhf.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node testcluster-shard-00-01-acqhf.mongodb.net:27017: bad auth Authentication failed.
2017-11-20T11:58:33.101-0500 E QUERY [thread1] Error: can't authenticate against replica set node testcluster-shard-00-01-acqhf.mongodb.net:27017: bad auth Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1461:20
@(auth):6:1
@(auth):1:2
exception: login failed
我用我的用户名和密码替换了,但我仍然无法连接。我需要让mongod在后台运行吗?如果不是我需要做什么才能成功连接?谢谢。
答案 0 :(得分:4)
我必须使用不同的用户名和密码创建一个新用户,当我使用这些新凭据运行命令时,我可以连接。
答案 1 :(得分:2)
我的问题是我最近才在Atlas UI中设置/更改密码-他们花一分钟左右的时间来部署所有更改,甚至重置密码等。等到更改后,我才能登录待部署
答案 2 :(得分:1)
与其他人一样,不喜欢我的战俘。从命令行可以正常工作,但不能从Compass正常工作。检查故障排除页面https://docs.atlas.mongodb.com/troubleshoot-connection/#special-characters-in-connection-string-password。我的密码中有特殊字符。尝试将它们转义,然后回过头将我的密码重置为一些没有特殊字符的简单密码-花费了一分钟,但随后我轻松连接了。
答案 3 :(得分:0)
只需从密码中删除特殊字符即可。
答案 4 :(得分:0)
有时值得重置本地服务。运行 where to_char(to_date(month_name,'MONTH'),'Q') =
to_char(add_months(sysdate,9),'Q');
,然后运行 brew services stop mongodb-community
。