Skip to content

Instantly share code, notes, and snippets.

@cdimascio
Last active April 20, 2018 13:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdimascio/84700f98cc285bfba6a64e63abfbced5 to your computer and use it in GitHub Desktop.
Save cdimascio/84700f98cc285bfba6a64e63abfbced5 to your computer and use it in GitHub Desktop.
Create MongoDB user via Mongo shell
# start the mongo shell, then set to the appropriate db and create a user
# in this case, create a user with dbadmin, and read write access roles
use my_db
db.createUser( { user: "my_user", pwd: "MyP@ssw0rd", roles: [ { role: "readWrite", db: "my_db"}, { role: "dbAdmin", db: "my_db" } ] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment