我有两个星展:
我有一个具有readWriteAnyDatabase
角色的用户,但他不能列出ops
db中的集合。
我有另一个具有root
角色的用户,他成功地列出了ops
db的集合。
我尝试查看ops
中的集合
我所犯的错误:
未授权执行命令: listCollections..。
使用mongodb: 3.4.7
在mongoDB配置中,我只添加了auto=true
。
原因是什么?
发布于 2017-09-26 10:25:40
您需要将"readWriteAnyDatabase“角色授予"admin”数据库的用户。
use admin
db.createUser({user:"test", pwd:"test", roles: ["readWriteAnyDatabase"]})
之后,您可以与该用户一起登录,并查看所有集合。
mongo -u test -p test --authenticationDatabase admin opt
Mongo> db
opt
Mongo> show collections
test_collection
Mongo>
https://dba.stackexchange.com/questions/186771
复制相似问题