I am running mongo 2.6.1 on windows, I wanted to crate a user and then grant roles to the user for different dbs.
These are the commands I ran
mongo admin -u superuser -p 12345678
db.createUser({'user':'test4', 'pwd':'test4', roles:[{'role':'read', 'db':'db1'}]});
After this I can log in to db1 when I run
mongo db1 -u test4 -p test 4
After this I logged out and ran the following
mongo admin -u superuser -p 12345678
db.grantRolesToUser( "test4", [ { role: "readWrite", db: "db2" } ])
Now when I run the following
mongo db2 -u test4 -p test 4
I get the error
MongoDB shell version: 2.6.1
connecting to: db1
2014-12-11T13:35:29.891-0500 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed
in Admin, show users shows that test4 has expected access to the dbs.
Can someone please explain what I am missing? How do I fix this?
Regards