0
0
MongoDBquery~10 mins

Creating users and roles in MongoDB - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new user with read-only access to the 'sales' database.

MongoDB
db.createUser({ user: "readonlyUser", pwd: "password123", roles: [ { role: [1], db: "sales" } ] })
Drag options to blanks, or click blank then click option'
AreadWrite
BdbAdmin
Cread
DuserAdmin
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'readWrite' which allows writing, not just reading.
Using 'dbAdmin' which is for database administration, not just reading.
2fill in blank
medium

Complete the code to create a role that allows users to read and write on the 'inventory' database.

MongoDB
db.createRole({ role: "inventoryManager", privileges: [], roles: [ { role: [1], db: "inventory" } ] })
Drag options to blanks, or click blank then click option'
AreadWrite
BclusterAdmin
CdbAdmin
Dread
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting 'read' which does not allow writing.
Choosing 'clusterAdmin' which is for cluster-wide administration.
3fill in blank
hard

Fix the error in the code to create a user with the 'userAdmin' role on the 'admin' database.

MongoDB
db.createUser({ user: "adminUser", pwd: "securePass", roles: [ { role: [1], db: "admin" } ] })
Drag options to blanks, or click blank then click option'
AreadWrite
Bread
CdbOwner
DuserAdmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'readWrite' which does not grant user management permissions.
Choosing 'read' which only allows reading data.
4fill in blank
hard

Fill both blanks to create a role 'reportViewer' that can read data and run aggregation on the 'reports' database.

MongoDB
db.createRole({ role: "reportViewer", privileges: [ { resource: { db: "reports", collection: "" }, actions: [ [1], [2] ] } ], roles: [] })
Drag options to blanks, or click blank then click option'
Afind
Baggregate
Cinsert
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'insert' or 'remove' which allow modifying data.
Missing the 'aggregate' action needed for aggregation.
5fill in blank
hard

Fill all three blanks to create a user 'dataAnalyst' with a custom role that allows reading and running aggregation on the 'analytics' database.

MongoDB
db.createRole({ role: [1], privileges: [ { resource: { db: [2], collection: "" }, actions: [ "find", "aggregate" ] } ], roles: [] }); db.createUser({ user: "dataAnalyst", pwd: "pass456", roles: [ { role: [1], db: [2] } ] })
Drag options to blanks, or click blank then click option'
AanalyticsReader
Banalytics
Cread
DreadWrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using built-in roles instead of the custom role name.
Mismatching the database name between user and role creation.