[英]Creating a mongo user with access to listCollections on a particular database
I've created a user with the role readWrite
using:我使用以下命令创建了一个具有readWrite
角色的用户:
use reporting
db.createUser(
{
user: "reportsUser",
pwd: "12345678",
roles: [
{ role: "readWrite", db: "reporting" }
]
}
)
which I thought would give it access to listCollections
as described on https://docs.mongodb.com/manual/reference/built-in-roles/ .我认为它可以访问listCollections
,如https://docs.mongodb.com/manual/reference/built-in-roles/中所述。 However, as soon as I turned on security.authorization
in my /etc/mongod.conf
file, that command stopped working - with the error:但是,一旦我在我的/etc/mongod.conf
文件中打开security.authorization
,该命令就停止工作 - 并出现错误:
command listCollections requires authentication' on server x.x.x.x:27017. The full response is { "ok" : 0.0, "errmsg" : "command listCollections requires authentication", "code" : 13, "codeName" : "Unauthorized" }
Any ideas what permission / role I need to do to allow this command?任何想法我需要做什么权限/角色才能允许此命令?
Got the same problem.遇到了同样的问题。 It works for me when I add --authenticationDatabase admin
with mongo -u admin -p password
当我使用mongo -u admin -p password
添加--authenticationDatabase admin
时,它对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.