无法在mongodb中创建角色

时间:2018-03-13 15:03:14

标签: mongodb centos7

我正在尝试在mongodb中创建一个新角色,但它给了我错误:

> use Admin
switched to db Admin
> db.createRole( { role: "executeFunctions", privileges: [ { resource: { anyResource: true }, actions: [ "anyAction" ] } ], roles: [] } );
2018-03-13T19:59:25.114+0500 E QUERY    [thread1] Error: Roles on the 'Admin' database cannot be granted privileges that target other databases or the cluster :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createRole@src/mongo/shell/db.js:1541:1
@(shell):1:1

1 个答案:

答案 0 :(得分:4)

有些时候mongo使用错误的法术并稍后创建问题。

所以检查:

use admin
switched to db admin
> db.createRole( { role: "executeFunctions", privileges: [ { resource: { anyResource: true }, actions: [ "anyAction" ] } ], roles: [] } );