mongodb 如何列出mongo shell中的所有用户?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32582244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to list all users in the mongo shell?
提问by naXa
In the MongoDB shell, how do I list all users for the current database that I'm using?
I can't seem to find it anywhere on stackoverflow.
在 MongoDB shell 中,如何列出我正在使用的当前数据库的所有用户?
我似乎无法在 stackoverflow 上的任何地方找到它。
回答by naXa
You can do:
你可以做:
db.getUsers()
or
或者
show users
The both commands print a list of users for the current database. See MongoDB documentation for User Management.
这两个命令都打印当前数据库的用户列表。有关用户管理,请参阅 MongoDB 文档。
回答by Hamit YILDIRIM
List belong to db users:
属于 db 用户的列表:
use db_name
and db.getUsers()
or show users
use db_name
和db.getUsers()
或show users
List according the authentication type:
按认证类型列出:
db.getUsers({ filter: { mechanisms: "SCRAM-SHA-256" } })
List with the credental:
列出凭证:
db.getUsers( {showCredentials: true, filter: { mechanisms: "SCRAM-SHA-256" }} )