Modify the default MongoDB administrator password

You can modify the MongoDB password using the following command at the shell prompt:

$ mongo admin --username root --password YOURPASSWORD
MongoDB shell version v3.4.10
connecting to: mongodb://
MongoDB server version: 3.4.10
> db = db.getSiblingDB('admin')
> db.changeUserPassword("root", "NEWPASSWORD")
> exit

NOTE: Remember that both YOURPASSWORD and NEWPASSWORD are placeholders. Replace them with your current password and with the new password you want to set.

Last modification September 5, 2018