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:
题目选项
- A.$ mongo foundation
- B.> use admin
- C.> db.auth("hari.seldon", "raven")
- D.$ mongo -u hari.seldon -p raven --authenticationDatabase foundation
- E.$ mongo test
- F.> use foundation
- G.> db.auth("hari.seldon", "raven")
答案置信度:低
正确答案:C、D、E、F、G
解析语言:中文
源文档把选项按行拆开,实际是三组命令:(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 库里并没有这个用户,会认证失败。因选项被拆行、原始分组需要还原,故置信度低。