翻译或纠错本页面
- Reference >
- mongo Shell Methods >
- User Management Methods >
- db.changeUserPassword()
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")