In MongoDB 2.6.1 I've setup a user with dbAdmin rights:
{ "_id" : "mydbname.myusername", "user" : "myusername", "db" : "mydbname", "credentials" : { "MONGODB-CR" : "<some credentials>" }, "roles" : [ { "role" : "dbAdmin", "db" : "mydbname" } ] }
When I use the mongo shell to connect to the database (using -u and -p on command line) and run a query like this:
db.mycollectionname.find()
I get this error:
error: { "$err" : "not authorized for query on mydbname.request", "code" : 13 }
Any ideas what can be happening?
So far I've tried adding every role I can find to the user but that hasn't helped.
You need to assign the read
role to the user in question.
The dbAdmin
role does not include read access on non-system collections.
For anybody running into this problem against Mongo 3.0.6, I fixed by adding
?authMode=scram-sha1
at the end of my mongodb uri.
Here are some docs explaining the purpose of scram-sha1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With