How to change MongoDB User Password

In this article, we will describe How to change MongoDB User Password.

Syntax to change MongoDB User Password:

db.changeUserPassword(username, password)

Where
username: The name of the user whose password we wish to change.
password: The user’s new password.

Permissions required to change are current use must have built-in role “userAdmin”.

Examples to change MongoDB User Password:

1. Change password for user mapp1 on the database m201.

use m201

db.changeUserPassword("mapp1", "admin@123") db.changeUserPassword("mapp1", passwordPrompt())

Leave a Reply

Your email address will not be published. Required fields are marked *