如何以非管理员身份更改我的mongoDB用户密码? [英] How to change my mongoDB user password as non administrator?

查看:136
本文介绍了如何以非管理员身份更改我的mongoDB用户密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解我可以通过以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用户密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆