sudo systemctl start mongod code example
Example 1: Failed to enable unit: Unit file mongod.service does not exist.
> sudo systemctl enable mongodb.service
Example 2: start mongodb service ubuntu
sudo systemctl start mongod
sudo systemctl stop mongod
Example 3: Failed to enable unit: Unit file mongod.service does not exist.
> systemctl list-unit-files --type=service
...
mongodb.service disabled
...
Example 4: Failed to enable unit: Unit file mongod.service does not exist.
> cd /lib/systemd/system
> sudo touch mongodb.service
> sudo nano mongodb.service
[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
After=network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
[Install]
WantedBy=multi-user.target
Example 5: ubuntu start mongodb
sudo mongod --fork --config /etc/mongod.conf