Understanding Explain for Sharded Clusters - unable to shard

Hi,
I am trying to run the commands in Understanding Explain for Sharded Clusters lecture as given in the lecture materials understanding_explain_part_2.js.
However, I am getting error message as given below:
MongoServerError: (Unauthorized) not authorized on admin to execute command { enableSharding: “m201”, lsid: { id: {4 [91 135 115 121 162 34 70 17 132 180 107 179 48 9 115 34]} }, $clusterTime: { clusterTime: {1644971864 4}, signature: { hash: {0 [190 186 102 82 221 170 54 147 106 27 96 254 229 184 86 66 143 115 20 23]}, keyId: 7004158947498131456.000000 } }, $db: “admin” }

Also can we use these sharding commands from compass as well?

Any guidance greatly appreciated.
Thank you
Siva

Can you show how you connected to your db?

I used the below connection string from powershell in MS DOS:

mongosh “mongodb+srv://sandbox.x8wir.mongodb.net/m001-mongodb-basics” --username m001-student and password.

then I switched to m201. I though I should have admin rights, so switched to admin database and tried to create admin user with

db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

Getting error as Unauthorized, I am not sure If I have to create a “Global user” first.
Thank you

Your earlier command was enableSharding
You cannot do sharding on shared cluster
What are the requirements for this course?
I think you should have mongodb installed on your local host

m001-student has restricted privileges

Thanks for the response Ram,

I am trying the commands given in understanding_explain_part_2.js part of indexes lesson

Yes I do have mongodb installed on local host.

I could connect to it by giving “mongosh” command from MS DOS powershell.

I created m201 database and imported people collection through compass, could not do from prompt.

mongoimport is not defined and also there is a warning that browser list not updated, what do to about it?

Please see the screenshot for all the commands that I gave and system responses. :frowning:
regards
siva

Why import does not work?
You are running it at mong prompt which is not correct.Run at windows command prompt
You have to run enablesharding on mongos instance
Have you setup your replicas,sharded clusters and mongos?
Please check m103 cluster administration course

Hi Ram,
I am unable to run mongoimport from command prompt error as not recognized cmdlet etc.,
I made suitable additions in environment variables for user and system variables for starting mongosh from command prompt.
I passed m103 course, I will check again if I am missing something.

Thank you
Siva