NOTE: This tutorial does not cover the installation of MongoDB on any of the operating systems discussed in this post. Feel free to explore our tutorials on the topic to learn more.
Let’s dive in.
Start MongoDB Service on Windows
On Windows, you can manage the MongoDB service by using the Windows Service Manager.
Press the Win + R key and launch the Run utility. Enter the command as services.msc to launch the Windows Service Manager.
Locate the MongoDB service and right-click to start the MongoDB server.
Selecting the Start option will allow the Windows service manager to start the MongoDB Service automatically.
Method 1 – Start MongoDB (cmd)
You can also start the MongoDB service from the command prompt. Start by running the command prompt with elevated privileges:
Next, run the command as shown below to start the MongoDB service:
The command should return the output as shown:
The MongoDB Server (MongoDB) service is starting.
The MongoDB Server (MongoDB) service was started successfully.
Start MongoDB Service on MacOS
On macOS, you can start the MongoDB service using the Homebrew service manager as shown in the command below:
The above command requires MongoDB to be installed via the Homebrew package manager. You can check out our tutorial on the topic to learn more.
Start MongoDB Service on Linux
You can use the systemd manager on Linux to start the MongoDB service.
NOTE: This process needs the MongoDB packages installed via the default package manager.
Run the command as:
The above command will use the systemd manager to start the MongoDB service.
Stop MongoDB Service on Windows
To stop the MongoDB service on Windows, use the Windows Service manager and select the Stop option on the MongoDB service.
Stop the MongoDB Service With the Command Prompt
To stop the MongoDB service from the command line, start the command prompt with elevated privileges and run the command:
The command should return output as:
The MongoDB Server (MongoDB) service is stopping.
The MongoDB Server (MongoDB) service was stopped successfully.
Stop MongoDB Service on MacOS
On macOS, run the command below to stop the MongoDB server:
Stop MongoDB Service on Linux
On Linux, run the command below to stop the MongoDB service:
Termination
This article provides straightforward methods of starting and stopping the MongoDB service on Windows, macOS, and Linux.