Reputation: 41
I've got some rights issues with mongoDB, I created a DB admin using the auth menthod, and this worked.
I can connect from a distant server to my DB without any warning, using the admin account I created with the role "userAdminAnyDatabase". But, when I use a different DB (use myDB) I cannot run 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 "auth" in the configuration file, all work perfectly. But this is not what I want. I need that authentication method.
EDIT:
I just misunderstood the meaning of "userAdminAnyDatabase", this does not give you the rights to modify other DB. For this it seems to need the role "root" to fit super-user roles
Upvotes: 4
Views: 2474
Reputation: 707
when Mongod instance is opened with --auth option, it means that your datbase is authenticated. However connection to db is established without any authentication, but you are unable to perform any operation as it throws the error in your description since you are not authenticated. Now switch to authenticated db and then perform authentication using
db.auth( username, password ) Now you may be authorized to perform authorized operations on the db.
Upvotes: 4