Lab: Creating First Application User

Hello, I connected to the mongod instance on the port specified using the user credentials provided - here is the command-
mongo -u m103-admin -p m103-pass --port 27000
Then I tried to create the user - using below command -
db.createUser({user: "m103-application-user", pwd: "m103-application-pass", roles: [{role: "readWrite", db: "applicationData"} ] } )

The IDE displayed user successfully created -

But when i click “Run Test” i get the following message -
3 total, 0 passed, 0 skipped:
[FAIL] "The user m103-application-user was created on the admin database"

Did you create the ‘m103-application-user’ on the admin database?

[FAIL] "The user m103-application-user has the correct permissions"

Did you create the ‘m103-application-user’ with the readWrite role on the
applicationData database?

[FAIL] "The user m103-application-user has the correct password"

Did you create the ‘m103-application-user’ with the password

Hello, I did an F5/refresh on the web page and reloaded the IDE environment. Then I relaunched mongod and again created the user. It got created successfully.

Hi @NUSRAT_16306,

You might have created the user in the wrong database. I guess it could be the test database.

~ Shubham

For other users with this error:

The m103-admin user has also already been created for you, with password m103-pass

So the first step is to log in with authentication to mongo shell

mongo --port 27000 -u "m103-admin" -p "m103-pass" --authenticationDatabase "admin"

Related docs: mongodb-instance-with-authentication

missing authenticationDatabase option

If someone run this command:
mongo --port 27000 -u "m103-admin" -p "m103-pass"

Run show dbs:

use admin

And only then use the db.createUser() command.

After creating user this command is helpful for debugging.
getUsers docs





  • First connect using
    mongo --port 27000 -u m103-admin -p m103-pass

  • then shift to admin db
    use admin

  • then create the user with required role
    db.createUser({ user: "m103-application-user", pwd: "m103-application-pass", roles: [ {role: "readWrite", db: "applicationData"} ] }