## Step 3: Create a configuration file. 

Create a configuration file . This file can include any of the configuration options for mongod , but must include a valid setting for logpath : 

The following creates a configuration file, specifying both the logpath and the dbpath settings in the configuration file: 

echo logpath=c:\data\log\mongod.log> "C:\mongodb\mongod.cfg" echo dbpath=c:\data\db>> "C:\mongodb\mongod.cfg" 

## Step 4: Create the MongoDB service. 

Create the MongoDB service. 

sc.exe create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service 

sc.exe requires a space between “=” and the configuration values (eg “binPath= ”), and a “\” to escape double quotes. 

If successfully created, the following log message will display: 

[SC] CreateService SUCCESS 

## Step 5: Start the MongoDB service. 

net start MongoDB 

## Step 6: Stop or remove the MongoDB service as needed. 

To stop the MongoDB service, use the following command: 

net stop MongoDB 

To remove the MongoDB service, first stop the service and then run the following command: 

sc.exe delete MongoDB 

## Additional Resources 

• MongoDB for Developers Free Course 12 

• MongoDB for .NET Developers Free Online Course 13 

• MongoDB Architecture Guide 14 

