Mongodb – Start MongoDB With Authentication Enabled

mongodbmongodb-3.0

Well I am new in MongoDB. Just started using 2 tutorials from tutorialspoint and w3resource. I am really enjoying learning it. I think it is really the future of database management. However I have faced some problems and I want to clear my conceptions on those issues. Here is the first question of the stack of noted questions. Any help will be highly appreciated.

I use Ubuntu 14.04 LTS (32bit machine and O/S). My MongoDB version is 2.6.11. I use terminal to toy with MongoDB. According to MongoDB website I start the server mongod using this command…

$sudo service mongod start

Now to start the server with authentication enabled what should be the command? I tried using

$sudo service mongod --auth start

but it doesn't work.

Best Answer

Regarding the issue described in above mentioned post I suggest you to check authentication options into mongodb configuration file.

# Turn on/off security.  Off is currently the default
#noauth = true
auth = true

And after it initialize mongod service using auth mode.

sudo mongod --auth --dbpath /var/lib/mongodb

Auth configuration option should be set to true and accordingly mongo service will start in authentication mode.