Skip to content

Instantly share code, notes, and snippets.

@arekgotfryd
Created February 20, 2018 13:24
Show Gist options
  • Save arekgotfryd/87649b197052120d206dfa235bfa3f2a to your computer and use it in GitHub Desktop.
Save arekgotfryd/87649b197052120d206dfa235bfa3f2a to your computer and use it in GitHub Desktop.
Proper auth enablement for fresh mongo installation
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