MongoDB DBA · Question 514 · Multiple choice

32. Let's assume an administrator created a user account with the following commands on a replica set with authorization turned on: $ mongo use foundation db.createUser({user: "hari.seldon", pwd: "raven", roles: ["readWrite"]}) Which of the following commands will successfully authenticate the 'hari.seldon' user? Check all that apply:

Answer options

  1. A.
    $ mongo foundation
  2. B.
    > use admin
  3. C.
    > db.auth("hari.seldon", "raven")
  4. D.
    $ mongo -u hari.seldon -p raven --authenticationDatabase foundation
  5. E.
    $ mongo test
  6. F.
    > use foundation
  7. G.
    > db.auth("hari.seldon", "raven")

Answer confidence: Low

Correct answer: C, D, E, F, G

Explanation language: Chinese

源文档把选项按行拆开,实际是三组命令:(A)(B)(C) 为 mongo foundation → use admin → db.auth;D 为 mongo -u hari.seldon -p raven --authenticationDatabase foundation;(E)(F)(G) 为 mongo test → use foundation → db.auth。用户 hari.seldon 建在 foundation 库中,所以单条带 --authenticationDatabase foundation 的命令(D)以及先切到 foundation 再 db.auth 的那组(E、F、G)都能认证成功;而 (A)(B)(C) 这组把 db.auth 跑在 admin 库上,admin 库里并没有这个用户,会认证失败。因选项被拆行、原始分组需要还原,故置信度低。

Papers containing this question

This question appears in 1 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 ↗