I just installed a fresh mongodb on Ubuntu server and when i try to adduser i am getting error
db.createUser(
{
user: "admin",
pwd: "ADYkdfd332@@33",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
2018-07-03T13:29:41.556+0530 E QUERY [thread1] Error: couldn't add user: Use of SCRAM-SHA-256 requires undigested passwords :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
In MongoDB, users are created using createUser() method. This method creates a new user for the database, if the specified user is already present in the database then this method will return an error.
createUser() on the $external database to create users who have credentials stored externally to MongoDB.
MongoDB: db. grantRolesToUser() method is used to grants an additional role and its privileges to a user. The name of the user to whom to grant roles. An array of additional roles to grant to the user. The level of write concern for the modification.
This works for me:
db.createUser({
user:"test1",
pwd:"test1",
roles:[
{
role:"readWrite",
db:"u8"
}
],
mechanisms:[
"SCRAM-SHA-1"
]
})
If you use User Management Methods you have to set param passwordDigestor
.
db.createUser(
{
user: "admin",
pwd: "ADYkdfd332@@33",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ],
passwordDigestor: "<server|client>"
}
)
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