- Start mongod without auth enabled
Make sure this is commented or missing from
/etc/mongod.conf
#security:
# authorization: enabled
The service should be running:
$ sudo service mongod start
- Create admin user and db users
$ use admin
$ db.createUser({user: 'admin', pwd: 'super secret password', roles: [{role: 'root', db: 'admin'}]})
$ use newDatabase
$ db.createUser({user: 'newDatabaseUser', pwd: 'super secret password', roles: [{role: 'readWrite', db: 'newDatabase'}]})
...
- Enable Auth
Add the following to
/etc/mongod.conf
:
security:
authorization: enabled
- Restart mongod
$ sudo service mongod restart