- Security >
- Security Tutorials >
- User and Role Management Tutorials >
- Change a User’s Password
Change a User’s Password¶
Changed in version 2.6.
On this page
Overview¶
Strong passwords help prevent unauthorized access, and all users
should have strong passwords. You can use the openssl
program to
generate unique strings for use in passwords, as in the following
command:
Prerequisites¶
You must have the changeAnyPassword
action on a database to modify the password of any user on
that database.
To change your own password, you must have the
changeOwnPassword
action
on your database. See
Change Your Password and Custom Data.
Procedure¶
Connect to MongoDB with the appropriate privileges.¶
Connect to the mongod
or mongos
with the privileges
specified in the Prerequisites section.
The following procedure uses the siteUserAdmin
created in
Create a User Administrator.
Change the password.¶
Pass the user’s username and the new password to the
db.changeUserPassword()
method.
The following operation changes the reporting
user’s password to
SOh3TbYhxuLiW8ypJPxmt1oOfL
: