MongoDB DBA · 题目 308 · 多选

27. Which of the following commands will successfully create the user "dsj" and give the user read-only access to all the collections in the "nasa" database? Check all that apply:

题目选项

  1. A.
    > use admin > db.createUser({ "user":"dsj", "pwd": "explorer", "roles": [{"role": "read", "db": "nasa", "col": "*"}] })
  2. B.
    > use admin > db.createUser({ "user":"dsj", "pwd": "explorer", "roles": [{"role": "read", "db": "nasa"}] })
  3. C.
    > use nasa > db.createUser({ "user":"dsj", "pwd": "explorer", "roles": [{"role": "read", "db": "nasa"}] })

答案置信度:中

正确答案:B、C

解析语言:中文

A 中角色文档里的 col 不是合法字段(合法字段只有 role 和 db,要让角色覆盖某库所有集合只需写 {role:"read", db:"nasa"}),所以 A 会报错。B 在 admin 库创建用户并授予 nasa 的 read 角色可行;C 在 nasa 库创建用户并授予本库 read 角色同样可行,只是该用户需以 nasa 作为认证库,因此两项都满足题意。

所在套题

此题在题库中有 3 条记录。公开详情合并相同题干和选项;完整公开题展示置信度最高的一条记录,其他题目仅展示摘要。按套学习保留每条记录原有的答案、解析和置信度。

作者 · 作品 · 开源

作者与 MongoDB 作品

专注数据平台、MongoDB 迁移同步与云运维产品研发。

有任何 MongoDB 需求,均可联系作者。

联系作者 ↗mlhp123@outlook.com

支持作者

如果题库对您有帮助,欢迎自愿扫码打赏。

支付宝扫码打赏作者打开打赏原图 ↗