Created
May 29, 2023 13:43
-
-
Save Maurifc/2836809e50b02bf442ef38fa55e173e4 to your computer and use it in GitHub Desktop.
Snippet for creating mongodb user
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
// Backup | |
db.createUser({ | |
user: "bkp", | |
pwd: "PASSWORD-123", | |
roles: [ | |
{ role: "readAnyDatabase", db: "admin" }, | |
{ role: "backup", db: "admin" } | |
] | |
}) | |
// Read write and admin of a database | |
db.createUser( | |
{ | |
user: "robert", | |
pwd: "1234566", | |
roles: | |
[{ | |
role: 'readWrite', | |
db: 'database-name' | |
}, | |
{ | |
role: "userAdmin", | |
db: "database-name" | |
}] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment