In this lab, students are asked to create a user account on a running MongoDB instance. After completing this lab, students will have hands-on experience enabling access control and creating user accounts on MongoDB.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Enable Access Control
Create an admin user account and grant it the
userAdminAnyDatabase
andreadWriteAnyDatabase
built-in roles.Edit
/etc/mongod.conf
and add the following:security: authorization: enabled
Restart the mongodb service.
- Connect as Admin User
Connect using the user created in the previous step.
- Create Standard User Account
Create a user account named
test
with thereadWrite
role on thetest
database and theread
role on thereporting
database.Connect to the MongoDB instance using the newly created user account.