Create an administrator with the role "dbAdminAnyDatabse" with mongodb v2.4.8
I created an admin user for my mongo installation as follows:
> use admin
> db.addUser( { user: "test",
pwd: "password",
roles: [ "dbAdminAnyDatabse",
otherDBRoles:
{
"otherTestDB": [ "readWrite" ]
}]
} )
When I try to connect to "otherTestDB" using the user: "test" and pwd: "password" with the robomongo or java driver, I get the wrong authentication error.
where is the mistake?
admin db, userid db, TestDB. DBRoles dbs db . , addUser, , , admin db, otherTestDB:
$ mongo otherTestDB --username test --password password --eval 'printjson(db.c.findOne())'
connecting to: otherTestDB
Thu Feb 27 10:45:20.722 Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228
, db, otherTestDB getSiblingDB, :
$ mongo admin --username test --password password --eval 'printjson(db.getSiblingDB("otherTestDB").c.findOne())'
connecting to: admin
{ "_id" : ObjectId("530f5d904dbd43cfb46aab5b"), "hello" : "world" }
, , otherTestDB , TestDB.
?