Created
May 15, 2022 20:02
-
-
Save cppshane/12596c9921f73f8ccd468d2a6cb5067a to your computer and use it in GitHub Desktop.
Mongo Initial Permissions
This file contains hidden or 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
# Why does initial setup of Mongo always give me permission issues? | |
mongosh | |
use admin | |
db.createUser( | |
{ | |
user: "adminUser", | |
pwd: passwordPrompt(), | |
roles: [ | |
{ role: "userAdminAnyDatabase", db: "admin" }, | |
{ role: "readWriteAnyDatabase", db: "admin" } | |
] | |
} | |
) | |
use example_database | |
db.createUser( | |
{ | |
user: "shane", | |
pwd: passwordPrompt(), | |
roles: [ | |
{ role: "readWrite", db: "example_database" } | |
] | |
} | |
) | |
# set the following in /etc/mongo.conf | |
# security: | |
# authorization: enabled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment