如何以非管理员身份更改我的mongoDB用户密码?

编程入门 行业动态 更新时间:2024-10-28 19:19:57
本文介绍了如何以非管理员身份更改我的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用户密码?

本文发布于:2023-06-07 13:25:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/560848.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户密码   管理员   身份   mongoDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!