How to enable password authentication in MongoDB 3.x
30 Apr 2016Create one admin user in the special db admin
like this:
$ mongo
> use admin
> db.createUser({user:"root-username",pwd:"root-password", roles:[{role:"root",db:"admin"}]})
> exit
Now open /ect/mongod.conf
in your favorite text editor and enable authentication by adding this to it:
security:
authorization: enabled
Now restart your mongodb sudo service mongod restart
.