db.addUser({ user: "Carlos",
pwd: "pwd",
customData: { employeeId: 12345 },
roles: [
{ role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" },
"readWrite"
]
})
This is an example setup script in mongo wiki http://docs.mongodb.org/manual/reference/method/db.addUser/
Whats wrong with this script... I am getting
{
"user" : "Carlos",
"pwd" : "ccb9d76967dcb0315ab62e88cb5c372b",
"customData" : {
"employeeId" : 12345
},
"roles" : [
{
"role" : "clusterAdmin",
"db" : "admin"
},
{
"role" : "readAnyDatabase",
"db" : "admin"
},
"readWrite"
],
"_id" : ObjectId("5444963f3507d43d2138fa6f")
}
uncaught exception: couldn't add user: Roles must be non-empty strings.
This works in Mongo 2.4.5
db.addUser({ user: "dbOwner", pwd: "dbOwner", roles: [ "dbOwner", "DBNAME" ]})
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