Created
January 19, 2023 20:01
-
-
Save shadyrudy/7d99d8264a6f2c4eb1419de1cf0390c0 to your computer and use it in GitHub Desktop.
List all users and roles in MongoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following MongoDB script displays all users and roles for all databases. | |
// Appropriate permissions are required to run this script | |
use admin | |
// Increase the number of documents returned by the find command | |
// Use either the legacy mongo shell version or Mongosh version | |
// Legacy Mongo Shell version | |
DBQuery.shellBatchSize = 300 | |
// Mongosh version | |
config.set("displayBatchSize", 300) | |
// Display all users, along with their databases and roles | |
db.system.users.find({},{db:1,user:1,roles:1}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment