List Users列出用户

To list all users, use mongosh to query the system.users collection:要列出所有用户,请使用mongosh查询system.users集合:

use admin
db.system.users.find()
Important重要

Do not modify the system.users collection directly. 不要直接修改system.users集合。To manage users, use the designated user management commands.要管理用户,请使用指定的用户管理命令

To list all users of a sharded cluster that were created through a mongos, connect to a mongos and run the preceding command. MongoDB stores users that are created through a mongos in the admin database of the config servers.要列出通过mongos创建的分片集群的所有用户,请连接到mongos并运行前面的命令。MongoDB将通过mongos创建的用户存储在配置服务器的管理数据库中。

To list all shard local users, connect to the respective shard directly and run the preceding command. 要列出所有分片本地用户,请直接连接到相应的shard并运行前面的命令。MongoDB stores shard local users in the admin database of the shard itself. MongoDB将分片本地用户存储在分片本身的admin数据库中。These shard local users are independent from the users added to the sharded cluster through a mongos. 这些shard本地用户独立于通过mongos添加到分片集群的用户。Shard local users are local to the shard and are inaccessible to mongos.分片本地用户是分片的本地用户,mongos无法访问。

←  Authenticate a UserRole-Based Access Control →