我在过去的某个时候使用 db.addUser(...) 创建了一个用户。我现在如何更改该用户的密码?
我使用具有 userAdmin 角色的用户登录。我使用什么命令来更改其他用户的密码?
编辑2
我需要为 v2.4 样式的 addUser 和权限文档回答这个问题
- http://docs.mongodb.org/manual/tutorial/add-user-to-database/
- http://docs.mongodb.org/manual/reference/privilege-documents/
编辑
有人建议我使用 2.2 addUser 语法来更改密码。这不起作用:
db.addUser({user: "test", pwd: "oldPassword", roles: ["readWrite"]})
db.addUser("test", "newPassword")
给予
uncaught exception: couldn't add user: system.users entry must not have both 'roles' and 'readOnly' fields
最佳答案
db.changeUserPassword("test", "newPassword")
https://groups.google.com/d/msg/mongodb-user/KkXbDCsCfOs/rk2_h-oSbAwJ https://jira.mongodb.org/browse/DOCS-1515
终于找到了!
关于mongodb - 如何更改 MongoDB 用户的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16612081/