Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have started using MongoDB with authentication. As per the documentation I used the localhost exception to create an admin user with the single role of userAdminAnyDatabase. That all went fine. When I run the "mongo" client and authorize against the admin database after using that database I get the number 1 indicating that authorization succeeded. However, any command I try to execute results in an "unauthorized" error, even trying to show the collections in the admin database I just authorized against.

Can anyone tell me why this is and how I can fix it? Currently I am running without authentication until I can get this fixed.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

The userAdminAnyDatabase role (and the userAdmin role that it is an extension of) simply gives your user the permission to read and write to the system.users collection to administer the users of a database. It doesn't allow the user to read or write to the actual collections of the database. For that, you need to grant the read or readWrite roles.

See User Privilege Roles in MongoDB and Add a User to a Database.

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.