To list all users, use 要列出所有用户,请使用mongosh
to query the system.users collection:mongosh
查询system.users集合:
use admin db.system.users.find()
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 MongoDB将分片本地用户存储在分片本身的admin
database of the shard itself. admin
数据库中。These shard local users are independent from the users added to the sharded cluster through a 这些shard本地用户独立于通过mongos
. mongos
添加到分片集群的用户。Shard local users are local to the shard and are inaccessible to 分片本地用户是分片的本地用户,mongos
.mongos
无法访问。