restart mongodb ubuntu code example

Example 1: mongodb install in ubuntu

sudo apt update
sudo apt install -y mongodb
//checking service and db
sudo systemctl status mongodb
or service mongodb status
//start service
sudo systemctl start mongod
or service mongodb start
//stop service
sudo systemctl stop mongod  or
service mongodb stop

Example 2: how to restart mongodb server in ubuntu

sudo systemctl restart mongodb
# it will restarts running mongodb server

Example 3: mongodb restart command ubuntu

sudo systemctl restart mongod

Example 4: start mongodb service ubuntu

sudo systemctl start mongod
sudo systemctl stop mongod

Example 5: how to stop mongodb server in ubuntu

sudo systemctl stop mongodb
# it will stop running mongodb server

Example 6: ubuntu start mongodb

sudo mongod --fork --config /etc/mongod.conf

Tags:

C Example