Skip to content

Instantly share code, notes, and snippets.

@gabrielqmatos88
Forked from iwatakeshi/mongo.bash
Created June 11, 2018 18:04
Show Gist options
  • Save gabrielqmatos88/fab74641d905511fe45e659a924b608d to your computer and use it in GitHub Desktop.
Save gabrielqmatos88/fab74641d905511fe45e659a924b608d to your computer and use it in GitHub Desktop.
Create a Windows service for MongoDB
# Create directories
mkdir c:\mongo\db
mkdir c:\mongo\config
mkdir c:\mongo\log
# Create a configuration file
# in c:\mongo\config\ as
# 'mongod.cfg' and paste:
#|==================================|
#| logpath=C:\mongo\log\mongodb.log |
#| logappend=true |
#| dbpath=C:\mongo\db |
#|==================================|
# Create a Windows Service:
sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.0\bin\mongod.exe\" --service --config=\"C:\mongo\config\mongod.cfg\""
layName= "MongoDB" start= "auto"
# It should prompt: '[SC] CreateService SUCCESS'
# If so, then start the service:
net start MongoDB
# To stop serivce:
net stop MongoDB
# To delete service:
sc.exe delete MongoDB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment