Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the password in MongoDB for existing user

Tags:

I have production environment where my mongoDB is up and running and DBAs are asking us to change the password which we use for authentication. One way to do this is run the addUser command again with a new password as described in change password

> db.auth("app_user", "somepassword")
db.addUser("app_user", "new password")

This is as good as a adding a new user.

I understand that I have to restart mongod with the --auth option once I add a new user as described in but as this is a production env and I can't restart my server. Is there any other option ? or if my approach is wrong how to change the password in mongoDB

like image 801
Srivatsa N Avatar asked Apr 30 '13 14:04

Srivatsa N


People also ask

How can I change my MongoDB password?

If you have an old password and you want to change the password then user mongo --username <USERNAME> and then use db. changeUserPassword("<USERNAME>", passwordPrompt()) .

How can I see my MongoDB password?

By default mongodb has no enabled access control, so there is no default user or password. To enable access control, use either the command line option --auth or security.

How do I change user details in MongoDB?

To change another user's pwd or customData field, you must have the changePassword and changeCustomData actions respectively on that user's database. To modify your own password and custom data, you must have privileges that grant changeOwnPassword and changeOwnCustomData actions respectively on the user's database.


1 Answers

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

like image 70
Gabriel Avatar answered Sep 29 '22 12:09

Gabriel