On Cloud Mongo (Mongo Atlas) Free tier, it has 3 members of servers. How can I connect to the Secondary host from Mongo shell? Their example only shows how to connect to Primary.
"members" : [
{
"_id" : 0,
"name" : "***-shard-00-00-***.mongodb.net:27017",
....
},
{
"_id" : 1,
"name" : "***-shard-00-01-***.mongodb.net:27017",
.....
},
{
"_id" : 2,
"name" : "***-shard-00-02-***.mongodb.net:27017",
.....
}
]
You need to use the --ssl
flag and specify authSource
.
Try:
mongo "mongodb://***-shard-00-02-***.mongodb.net:27017/?authSource=admin" --ssl
at the very minimum. Of course you can add options for username, password, database to connect, etc...
mongo "mongodb://<username>:<password>@***-shard-00-02-***.mongodb.net:27017/<database>?authSource=admin" --ssl
I hope this helps.