- open mongod.conf
cd /etc/mongod.conf
- Comment security
#security:
# authroization: "enabled"
- Restart mongodb
sudo service mongod stop
sudo service mongod start
- Run mongo
mongo
- Run these cmds
use admin
db.createUser({user:"admin",pwd:"password",roles:[{role:"root",db:"admin"}]});
-
Enable auth again what you had commented in /etc/mongod.conf file (remove comments)
-
Restart mongod service again
-
DONE
I made some changes: https://gist.github.com/koficoud/00f496daed42bef0ed95c725a5771383/revisions