Skip to content

Instantly share code, notes, and snippets.

@mgmanalili
Forked from iwatakeshi/mongo.bash
Created July 19, 2018 07:03
Show Gist options
  • Save mgmanalili/53e3abc3190f28b85e05b8a730c2cc74 to your computer and use it in GitHub Desktop.
Save mgmanalili/53e3abc3190f28b85e05b8a730c2cc74 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