How to list all users in the mongo shell?
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.
List belong to db users:
use db_name
and db.getUsers()
or 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" }} )
If you like to list only user names and leave all other bulk info.. try
db.system.users.find({}, {"_id" : 1})