Tuesday, April 30, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 10298  / 2 Years ago, thu, december 16, 2021, 6:42:19

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.


More From » authentication

 Answers
0

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.


[#29794] Friday, December 17, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hreadsoplet

Total Points: 220
Total Questions: 108
Total Answers: 105

Location: Serbia
Member since Fri, Jun 3, 2022
2 Years ago
;