How to restart a NoSQL Database service like MongoDB?

To restart a MongoDB service, use the systemctl command on modern Linux systems. MongoDB runs as a system service called mongod that can be managed through systemd service management tools.

Syntax

sudo systemctl restart mongod
sudo systemctl status mongod
sudo systemctl enable mongod

Method 1: Using systemctl (Recommended)

Check the current status of MongoDB service ?

sudo systemctl status mongod
mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
   Docs: https://docs.mongodb.org/manual

Restart the MongoDB service ?

sudo systemctl restart mongod

Verify the service is running ?

sudo systemctl status mongod
mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2022-10-11 07:45:50 HST; 7s ago
   Docs: https://docs.mongodb.org/manual
   Main PID: 124287 (mongod)
   Memory: 135.4M
   CGroup: /system.slice/mongod.service
   ??154987 /usr/bin/mongod --config /etc/mongod.conf

Method 2: Using Legacy service Command

For older systems or compatibility, use the service wrapper ?

sudo service mongod restart
sudo service mongod status

Enable Auto-start on Boot

Configure MongoDB to start automatically when the system boots ?

sudo systemctl enable mongod
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service ? /lib/systemd/system/mongod.service.

Common systemctl Commands

Command Action
sudo systemctl start mongod Start MongoDB service
sudo systemctl stop mongod Stop MongoDB service
sudo systemctl restart mongod Restart MongoDB service
sudo systemctl enable mongod Enable auto-start on boot
sudo systemctl disable mongod Disable auto-start on boot

Conclusion

Use systemctl restart mongod to restart MongoDB on modern Linux systems. Always verify the service status after restarting and consider enabling auto-start for production environments using systemctl enable mongod.

Updated on: 2026-03-15T03:58:38+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements