0

I had a mongodb 2.2 database with auth enabled. but after upgrading to 2.4 my admin user can not login to any database other than admin database. I removed it from system.users then created another admin user with:

db.addUser( { user: "admin", pwd: "123456", roles: [ "userAdminAnyDatabase" ] } )

But again I can not login to any database except admin database. Can anyone help?

1 Answer 1

1

The short answer is, at least for the user you list: this is how it is supposed to work with the new user privilege model in 2.4+

To explain:

The userAdminAnyDatabase role means that the user you have now created will be able to grant access (for itself, or any other users) to any other database, hence the designation in the docs as a "super user". However, that does not automatically grant that admin user read/write permission on all those databases (though it can bestow them upon themselves). Hence that user can't authenticate against anything other than the admin DB, but by being able to do so, it can grant the relevant permissions elsewhere.

I think what you might be looking for is the readWriteAnyDatabase role, though I would recommend using that particular role sparingly (if at all) and instead grant access as needed, for greater security.

I can't really speak to the user permissions prior to removal, because they have not been listed, just the role of the new user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.