MongoDB (3.2) doesn't start on Lubuntu 16.04 LTS as a service

For whatever reason, whenever I try to start MongoDB as a service (sudo service mongod start) I get the following error:

Failed to start mongod.service: Unit mongod.service not found.

I followed the installation guide on the MongoDB site.


Solution 1:

The instructions/packages on the MongoDB site are currently available for LTS Ubuntu 12.04 and 14.04 only. The packages are set up to use upstart instead of systemd. You need to create a systemctl file to be ready for systemd. Create it by

sudo nano /etc/systemd/system/mongodb.service

It will look like

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Now you can start the service and check its state by

sudo systemctl start mongodb
sudo systemctl status mongodb

and finally enable it permanently by

sudo systemctl enable mongodb

(Source: How to Install MongoDB on Ubuntu 16.04)

Solution 2:

Just run sudo mongod to start the daemon and then sudo mongo to access the shell

Solution 3:

Running following command worked for me. Please run mongo with config file.
Just Run mongod --config /etc/mongod.conf.