Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 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

Your Answer


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.