Created
February 20, 2018 13:24
-
-
Save arekgotfryd/87649b197052120d206dfa235bfa3f2a to your computer and use it in GitHub Desktop.
Proper auth enablement for fresh mongo installation
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
1. Start mongo without authentication | |
`mongod --port 27017 --dbpath /data/db1` | |
2. Run mongo shell | |
`mongo --port 27017` | |
3. Run following command to give admin user root priviliges | |
use admin | |
db.createUser( | |
{ | |
user: "admin", | |
pwd: "password", | |
roles: [ { role: "root", db: "admin" } ] | |
} | |
); | |
exit; | |
4. Stop mongo | |
5. Start mongo with authentication enabled | |
`mongod --auth --port 27017 --dbpath /data/db1` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment