How to Start and Stop MongoDB Server?

MongoDB, a popular NoSQL database, is used by numerous users for its flexibility, scalability, and performance. It is very important to know how to start and stop a server before deep diving into mongoDB. In this article, we’ll provide a comprehensive guide on how to initiate and terminate MongoDB server instances on various platforms.

Method 1: Linux and macOS

Using the Command Line: This is the most common approach for these systems. You’ll need administrator privileges to perform these actions.

Step 1: Starting the server

service mongod start

Starting the MongoDB server

This command instructs the system’s service manager to start the mongod process, which is the core MongoDB daemon.

Step 2: Stopping the server

service mongod stop

Stopping the MongoDB server

This command tells the service manager to stop the mongod process.

Method 2: In Windows

Using Services: On Windows, MongoDB is typically installed as a Windows service. You can manage it through the Services interface.

Step 1: Starting the server

  • Open the Run dialog (press Windows key + R).
  • Type services.msc and press Enter. The Services window will open.
  • Locate the service named “MongoDB” or similar (check your documentation if unsure).
  • Right-click on the service and select “Start“.

Stopping the server:

  • Follow steps 1 and 2 mentioned above.
  • Right-click on the “MongoDB” service and select “Stop“.

service window

Remember : In some cases, the service name might differ (e.g., mongod.exe). Refer to your MongoDB documentation for the specific service name used in your installation.