MongoDB

Starting and Stopping MongoDB Service

This article will explore the commands for managing the MongoDB service on various operating systems.

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:

$ net start mongodb

The command should return the output as shown:

C:\Users\linuxhint>net start mongodb

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:

$ brew services start mongodb

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:

$ sudo systemctl start mongod

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:

$ net stop mongodb

The command should return output as:

C:\Users\linuxhint>net stop mongodb

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:

$ brew service stop mongodb

Stop MongoDB Service on Linux

On Linux, run the command below to stop the MongoDB service:

$ sudo systemctl stop mongod

Termination

This article provides straightforward methods of starting and stopping the MongoDB service on Windows, macOS, and Linux.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list