Hi,
I 'm running mongod with authentication enabled.I wanted to create a Custom Role and assign Users to it.I executed the following queries:
> use admin
switched to db admin
> db.createRole(
... {
... role: "Role1",
... privileges: [
... { resource: { cluster: true }, actions: [ "killop", "inprog" ] },
... { resource: { db: "accounts", collection: "" }, actions: [ "killCursors" ] }
... ],
... roles: []
... }
... )
The above query successfully added the role named "Role1" to the collection system.roles under admin database.
Then I switched to the database accounts to create user
> use accounts
>> db.createUser(
... {
... user: "User1",
... pwd: "user1",
... roles: [ { role: "Role1", db: "accounts" } ]
... }
... )
2015-09-28T12:10:33.652+0530 Error: couldn't add user: No role named Role1@accounts at src/mongo/shell/db.js:1081
How to resolve this error????????