我了解我可以通过以MongoDB管理员身份运行db.changeUserPassword()来更改用户密码.但是,作为没有管理员权限的用户,我可以仅使用自己的帐户更改密码吗?
I understand I can change a user's password by running db.changeUserPassword() as an MongoDB administrator. However, as a user with no administrator privilege, can I change my password just with my own account?
谢谢
尽管Gergo提供的解决方案有效.但是我必须创建一个新角色才能正常工作.我认为changeOwnPassword应该是内置的特权,不需要其他管理工作.在MongoDB中,仅仅为了能够更改用户自己的密码而创建专用角色是过大的.
Although solution provided by Gergo worked. But I had to create a new role in order for it to work. I thought changeOwnPassword should be a built in privilege and not require additional admin work. Creating a dedicated role just for the purpose to be able to change user's own password is overkill in MongoDB.
推荐答案如果具有必要的特权,则可以更改自己的密码.您可以通过运行以下命令来验证您是否具有必要的特权:
If you have the necessary privileges, you can change your own password. You can verify that you have the necessary privileges by running this command:
db.runCommand( { usersInfo:"username", showPrivileges:true } )如果包含changeOwnPassword,则可以更改密码:
If it contains changeOwnPassword, then you can change the password:
db.runCommand( { updateUser: "username", pwd: "password" } )您可以在 MongoDB文档中找到更多信息. .
更多推荐
如何以非管理员身份更改我的mongoDB用户密码?
发布评论