简体   繁体   English

MongoDB:未经数据库授权执行命令eval

[英]MongoDB: Not authorized on database to execute command eval

This is the query i am running: 这是我正在运行的查询:

db.surveyquestion.copyTo('surveyquestionV2')

Error I am getting: 我得到的错误:

{
    "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
}

My user in admin db that i am using to run this query: 我正在运行此查询的admin数据库中的用户:

query:  db.getUsers();


/* 2 */
{
    "_id" : "admin.moiz",
    "user" : "moiz",
    "db" : "admin",
    "roles" : [
        {
            "role" : "root",
            "db" : "admin"
        }
    ]
}

I have this user with the root role but still i am unable to copy collection. 我有该用户具有root角色,但仍然无法复制集合。 Please help!! 请帮忙!!

To the people who has the same problem, the solution is in the documentation of db.eval() : just right here 对于有相同问题的人,解决方案在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. 不建议提供这种访问权限,但是如果您的组织要求用户运行eval,请创建一个在anyResource上授予anyAction的角色。 Do not assign this role to any other user. 不要将此角色分配给任何其他用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM