Updating a User
db.updateUser(username, update, writeConcern)
- username indicates the username to be updated.
- update is a document containing the replacement data for the user.
- writeConcern: The write concern level of the update operation. This parameter is optional.
db.updateUser(
"<username>",
{
customData : { <any information> },
roles : [
{ role: "<role>", db: "<database>" } | "<role>",
...
],
pwd: passwordPrompt(), // Or "<cleartext password>"
authenticationRestrictions: [
{
clientSource: ["<IP>" | "<CIDR range>", ...],
serverAddress: ["<IP>", | "<CIDR range>", ...]
},
...
],
mechanisms: [ "<SCRAM-SHA-1|SCRAM-SHA-256>", ... ],
passwordDigestor: "<server|client>"
},
writeConcern: { <write concern> }
) Field | Type | Description |
|---|---|---|
customData | Documents | Optional. Any information. |
roles | Array | Optional. The role assigned to the user. An update to the roles array overrides the previous array's values. |
pwd | string | Optional. The user's password. |
authenticationRestrictions | Array | Optional. The IP address or CIDR blocks that can be accessed by a role. |
mechanisms | Array | Optional. The specific SCRAM mechanism or mechanisms for the user credentials. Valid values are SCRAM-SHA-1 and SCRAM-SHA-256. |
passwordDigestor | string | Optional. Whether to verify the password on the server or client. The default value is server. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

