【发布时间】:2018-05-16 13:08:52
【问题描述】:
这是我正在运行的查询:
db.surveyquestion.copyTo('surveyquestionV2')
我得到的错误:
{
"message" : "MongoError: not authorized on GenericSurveyTool to execute command { $eval: function (collName, newName) {\r" +
"var from = db[collName];\r" +
"..., args: [ 'surveyquestion', 'surveyquestionV2' ], $db: 'GenericSurveyTool' }",
"stack" : "script:1:19",
"code" : 13
}
我用于运行此查询的管理数据库中的用户:
query: db.getUsers();
/* 2 */
{
"_id" : "admin.moiz",
"user" : "moiz",
"db" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
我有这个具有 root 角色的用户,但我仍然无法复制集合。请帮忙!!
【问题讨论】:
-
在你的角色数组中尝试使用
dbOwner而不是 root -
它不工作,同样的问题仍然存在。
-
只是为了确定,您是否在启动查询之前验证为 moiz ?
-
是的,这是肯定的
-
我刚刚在 db.eval() 命令的文档中看到了这一点:
If authorization is enabled, you must have access to all actions on all resources in order to run eval. Providing such access is not recommended, but if your organization requires a user to run eval, create a role that grants anyAction on anyResource. Do not assign this role to any other user.
标签: mongodb mongodb-query database-administration rbac