OPTIONS
翻译或纠错本页面

db.changeUserPassword()

Definition

db.changeUserPassword(username, password)

Updates a user’s password.

Parameter Type Description
username string Specifies an existing username with access privileges for this database.
password string Specifies the corresponding password.
mechanism string Optional. Specifies the authentication mechanism used. Defaults to MONGODB-CR. PLAIN is used for SASL/LDAP authentication, available only in MongoDB Enterprise.

Example

The following operation changes the reporting user’s password to SOh3TbYhx8ypJPxmt1oOfL:

db.changeUserPassword("reporting", "SOh3TbYhx8ypJPxmt1oOfL")