MongoDB DBA · Question 309 · Multiple choice

28. Consider the following existing user definition: use admin db.getUser('yulia') { "_id": "products.yulia", "user": "yulia", "db": "products", "roles": [ { "role": "dbAdmin", "db": "products" } ], ... ] } Which of the following commands would allow the user yulia to become a system administrator on the locations database? (assume you are running all commands as a root level user and have permissions to run all commands) Check all that apply:

Answer options

  1. A.
    db.createUser({ "user": "yulia", "pwd": "***", "roles": [{"db":"*", "role": "dbAdmin"}] })
  2. B.
    db.updateUser("yulia", {"roles": [{"db":"admin", "role": "dbAdminAnyDatabase"}]})
  3. C.
    db.updateUser("yulia", {"roles": [{"db":"locations", "role": "dbAdmin"}]})

Answer confidence: Medium

Correct answer: B, C

Explanation language: Chinese

A 不可行:yulia 已存在,createUser 会因用户重名失败,而且角色文档里 db:"*" 也不是合法写法(跨库要用 dbAdminAnyDatabase 这类角色名)。B 用 updateUser 把角色替换为 dbAdminAnyDatabase(覆盖 locations),C 直接授予 locations 上的 dbAdmin,两者都能让 yulia 在 locations 上获得管理员权限。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗