Mongodb – how to set mogodb in upstart service with authentication in mongodb way

mongodbstartupUbuntu

I set username and password in MongoDB every time I have to run this command in terminal:

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

As soon as I close terminal, MongoDB db also closes so how will I set MongoDB in startup service?

Best Answer

You need to use sudo service to start MongoDB as a service, check the documentation for further details:

sudo service mongod --auth --port 27017 --dbpath /var/lib/mongodb