Answer the question
In order to leave comments, you need to log in
mongodb: authentication problem
There is mongo on a separate server. Created user:
db.addUser( { user: "<username>",
pwd: "<password>",
roles: [ "userAdminAnyDatabase" ] } )
mongo --host <host> --port <port> -u <username> -p <password> --authenticationDatabase admin <dbname>
db.<collection>.find()
error: { "$err" : "not authorized for query on <dbname>.<collection>", "code" : 16550 }
Answer the question
In order to leave comments, you need to log in
Just ran into the same problem today. I used mongodb 2.6.1, its difference is that compared to 2.4.x, the users model in admin.system.users has changed and, accordingly, the system of rights and roles.
In order for the user to read the data, the following roles were added.
{
"user" : "<username>",
"db" : "<db_name>",
"credentials" : { "MONGODB-CR" : "xxxxxxxx" },
"roles" : [
{ "role" : "dbAdmin", "db" : "<db_name>" },
{ "role" : "readWrite", "db" : "<db_name>" },
{ "role" : "userAdminAnyDatabase", "db" : "admin" }
]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question