This version of the documentation is archived and no longer supported.

Change a User’s Password

New in version 2.4.

To change a user’s password, you must have the userAdmin role on the database that contains the definition of the user whose password you wish to change.

To update the password, pass the user’s username and the new desired password to the db.changeUserPassword() method.


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

db = db.getSiblingDB('records')
db.changeUserPassword("reporting", "SOhSS3TbYhxusooLiW8ypJPxmt1oOfL")


In previous versions of MongoDB, you could change an existing user’s password by calling db.addUser() again with the user’s username and their updated password. Anything specified in the addUser() method would override the existing information for that user. In newer versions of MongoDB, this will result in a duplicate key error.

For more about changing a user’s password prior to version 2.4, see: Add a User to a Database.