Skip to content

Instantly share code, notes, and snippets.

@iwatakeshi
Created April 22, 2015 02:02
Show Gist options
  • Save iwatakeshi/0e5142e2d40816f03468 to your computer and use it in GitHub Desktop.
Save iwatakeshi/0e5142e2d40816f03468 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
@mehdiHadji
Copy link

thank you !

@Joelthobias
Copy link

what is sc.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment