Skip to content

Instantly share code, notes, and snippets.

@Maurifc
Created May 29, 2023 13:43
Show Gist options
  • Save Maurifc/2836809e50b02bf442ef38fa55e173e4 to your computer and use it in GitHub Desktop.
Save Maurifc/2836809e50b02bf442ef38fa55e173e4 to your computer and use it in GitHub Desktop.
Snippet for creating mongodb user
// 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