"Show dbs" on M001 Atlas Cluster

I connected to the remote cluster okay, but I am getting errors when I do “show dbs”

MongoDB Enterprise Cluster0-shard-0:SECONDARY> show dbs
2019-02-26T13:29:14.567+0100 E QUERY [thread1] Error: listDatabases failed:{
“operationTime” : Timestamp(1551184145, 1),
“ok” : 0,
“errmsg” : “not master and slaveOk=false”,
“code” : 13435,
“codeName” : “NotMasterNoSlaveOk”,
“$clusterTime” : {
“clusterTime” : Timestamp(1551184145, 1),
“signature” : {
“hash” : BinData(0,“9bm54kmTPpnS+zAGAJUA6WFHzr8=”),
“keyId” : NumberLong(“6627672121604571137”)
} :


The details shows that you are in Secondary…I don’t know how it comes.
So, to understand it clearly could you please provide us the M001 cluster shell link while connecting through shell from your side?

Hi Oluseyi_12642,

By default, it is not allowed to read from Secondary server, you need to run rs.slaveOk() to enable reading from SECONDARY.


The remote server is at “cluster-shard-00-00-jxeqq.mongodb.net”, I connected to it by typing in the shell:

mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017” – authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

I got it now, this is your own sandbox cluster. So, what happened is that the replica set of your primary and secondary is changed. So, click on the cluster name and see how the clusters are managed.
Finally, try to connect with the same link by change to primary cluster number as shown in atlas profile.

For Ex:

cluster0-shard-00-00-dhmfv … (Secondary)
cluster0-shard-00-01-dhmfv… (Primary)

So try : mongo “mongodb://cluster0-shard-00-01-jxeqq.mongodb.net:27017” – authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics