M103 create a new user that has the readWrite role

Hi Ramachandra_Tummala:
Would you please help me.? As explained on the lecture tried to connect to the root level user:
~$mongo admin -u root -p m103-admin
but I keep getting the following error:

To connect to mongod it should be up &running
Is your mongod up?If yes on what port
Also check you are using correct user id & password
Follow instructions from your lab.Don’t compare or reproduce lecture steps.They may be using different environment and may not match your environment/setup

dear Ramachandra:
In the instruction from the lab is written that “connect to mongod instance that is already running in the background on 27000”.
I just type

mongo --port 27000 and mongo shell  gets connected to the mongod instance.

then I type :

  >use admin
  >db.createUser({user: "m103-application-user", pwd: "m103-application-pass",roles:["readWrite"]}) 

which must be authenticated.
to authenticate I type

> --username m103-admin 

I get error that “;” is missing.
would you please help?

Hi @farideh_gorji,

Welcome to the MongoDB Community forums :sparkles:

It seems like you are entering the incorrect command, due to which you are getting the error.

First thing you need to authenticate yourself as the m103-admin user which has already been created for you with password m103-pass.

After that, you need to modify your createUser command as per the problem statement:

like this (for reference):

  roles: [
    {role: "readWrite", db: "applicationData"}
  ]

If the problem still persists, please share the screenshot of the IDE along with the error to help you better?

Thanks,
Kushagra

2 Likes


Your mongod is running on port 27000 but you are trying to connect to default mongod on port ,27017
Hence connect fail error
Please pass port number to your command