Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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