MongoDB 指南针社区 : Databases are visible but their collections are not showing up after authentication

标签 mongodb mongodb-compass

我在 mongoshell 中使用以下命令创建了一个默认管理员用户:

use admin
db.createUser(
  {
    user: "root",
    pwd: "root",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

然后我使用 shell 和我的凭据进行身份验证,如下所示:mongo --port 27017 -u "root" -p "root" --authenticationDatabase "admin"
在 shell 中,我可以看到 usersversion集合使用:
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
test    0.000GB
> use admin
switched to db admin
> show tables
system.users
system.version
>

现在,当我尝试从 MongoDB Compass Community 访问这些表时,我首先进行身份验证:
enter image description here

现在管理数据库显示为空?

enter image description here

我如何才能像从 shell 一样从图形界面访问用户集合和其他集合?

最佳答案

看不到用户集合和其他集合的原因是 userAdminAnyDatabase 内置角色。默认情况下,它不需要必要的权限来读取这些集合。
根据您的需要尝试 root 或 dbAdminAnyDatabase。
干杯,
资源:
https://docs.mongodb.com/manual/reference/built-in-roles/

关于MongoDB 指南针社区 : Databases are visible but their collections are not showing up after authentication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62087007/

相关文章:

python - 如何在 Python Eve 中禁用自动生成的字段?

java - 无法连接到 Bluemix 中的 mongodb,找不到证书路径

mongodb - flutter 中 uri mongo_dart 中的方案无效

json - MongoDB 指南针 : How to select Distinct Values of a Field

mongodb - 如何使用 MongoDB Compass 对数据进行排序

mongodb - 如何在 mongodb compass 上插入具有当前日期和类型日期的文档

node.js - 语法错误 : Unexpected token U in JSON at position 0 at JSON. 在 angular8 中解析

php - 未找到类 'MongoDB\Cient'

javascript - Mongoose 验证不起作用

mongodb - regex options/i 等在 MongoDB Compass 中不起作用