changeUserPassword(username, password, mechanism? , digestPassword?)
This method takes two arguments. This method updates a user’s password.
Note:
Run the method in the database where the user is defined, i.e. the database you created the user.
Example 1: When user not present.
db.changeUserPassword('hello','hello')
uncaught exception: Error: Updating user failed: User hello@users not found : _getErrorWithCode@src/mongo/shell/utils.js:25:13 DB.prototype.updateUser@src/mongo/shell/db.js:1417:11 DB.prototype.changeUserPassword@src/mongo/shell/db.js:1421:5 @(shell):1:1
Example 2: When user is present.
db.changeUserPassword('userName','newPassword')
No comments:
Post a Comment