Changing the password in MongoDB for existing user

You linked to a question asking about adding authentication to MongoDB which involves starting 'mongod' with option --auth. Since you are already running with --auth the restart is not necessary in your scenario.

Just change the user password and you'll be set to go.


For v2.4

db.changeUserPassword("app_user", "new password")

https://groups.google.com/d/msg/mongodb-user/KkXbDCsCfOs/rk2_h-oSbAwJ https://jira.mongodb.org/browse/DOCS-1515


Starting of Mongodb 4.0, you have to use db.updateUser(), setting passwordDigestor key as "server", when updating the user password:

  • https://dba.stackexchange.com/questions/238847/cant-update-user-password-on-mongodb-4-0-5-use-of-scram-sha-256-requires-undig

MongoDB > 3.X

db.updateUser("root", {pwd: "NewRootAdmin" }) 

Reference: https://docs.mongodb.com/manual/reference/method/db.updateUser/