Last active
August 29, 2015 14:23
-
-
Save jperocho/c8c5ddc00d4bfe7b96f1 to your computer and use it in GitHub Desktop.
Mongodb auth in ubuntu 14.04
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
# Besure to comment auth=true In /etc/mongod.conf. | |
# Start the mongod or mongos instance without the authorization | |
$ sudo service mongod start | |
# Start mongo | |
$ mongo | |
# Inside mongo run the following | |
# Create admin user | |
> use admin | |
> db.createUser( | |
{ | |
user: "adminuser", | |
pwd: "1234567890", | |
roles: [ "root" ] | |
} | |
) | |
# Create database user | |
> use somedb | |
> db.createUser( | |
{ | |
user: "somedb_user", | |
pwd: "somedb_password", | |
roles: ["readWrite"] | |
} | |
) | |
> exit | |
# Stop and Start mongod with auth | |
# Comment auth=true In /etc/mongod.conf | |
$ sudo service mongod stop | |
$ sudo service mongod start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment