shell Register MongoDB as a Service

// install MongoDB on Windows Server

// create the relevant folders:
C:\data\
C:\logs\mongod.log

// create a new YAML configuration file:
C:\Program Files\MongoDB\Server\3.6\mongod.cfg

// add the configuration to the file:
systemLog:
  destination: "file"
  path: "C:\\logs\\mongod.log"
storage:
  dbPath: "C:\\data\\db"

// save the file

// register MongoDB as a Service
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.6\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

// start the MongoDB Service
net start MongoDB

// stop the MongoDB Service
net stop MongoDB

// remove the Service
sc.exe delete MongoDB
Use this to install MongoDB 3.6.17 (or similar) onto a Windows Server.

Updated: Sunday 20th September 2026, 22:14am

There are 0 comments

Leave a comment of your own

Comments are currently closed.