Mongodb administrator cannot start Command in another database (error code 13)

I have some mongoDB permissions issues, I created a database administrator using auth menthod and it worked.

I can connect from a remote server to my database without warning using the admin account I created with the userAdminAnyDatabase role. But, when I use another DB (use myDB), I cannot start db.runCommand.

Here is what I get:

> db.runCommand({createIndexes: "C_Cache", indexes: [{key: {tags: 1}, name: "tags_1"}]})
{
    "ok" : 0,
    "errmsg" : "not authorized on myDB to execute command { createIndexes: \"C_Cache\", indexes: [ { key: { tags: 1.0 }, name: \"tags_1\" } ] }",
    "code" : 13
}

When I comment out "auth" in the configuration file, everything works fine. But that I do not want. I need this authentication method.


EDIT:

I just misunderstood the meaning of "userAdminAnyDatabase", this does not give you the right to change another database. To do this, it seems that you need the "root" role to match the superuser roles.

+4
1

Mongod --auth, , - . db - , - , , . db,

db.auth( , ) db.

+4

Source: https://habr.com/ru/post/1540532/


All Articles