Mongodb User Creation Error:Couldn't add user:Use of SCRAM-SHA-256 requires undigested passwords

The MongoDB version used is 4.0.5

Use the following command to create a user

1
2
3
4
5
db.createUser({
user: "admin",
pwd: "xxx",
roles: [ {role: "userAdminAnyDatabase", db: "admin" } ]
})

The error message is as follows:

Error: Couldn’t add user: Use of SCRAM-SHA-256 requires undigested passwords

Solution: Change the encryption method to SCRAM-SHA-1.

1
2
3
4
5
6
db.createUser({
user: "admin",
pwd: "xxx",
roles: [{role: "userAdminAnyDatabase", db: "admin"}],
mechanisms: ["SCRAM-SHA-1"]
})

Mongodb User Creation Error:Couldn't add user:Use of SCRAM-SHA-256 requires undigested passwords
http://www.7-24.tech/en/2025/08/27/Mongodb-Error-couldn-not-add-user/