Skip to content

Instantly share code, notes, and snippets.

@dmmarmol
Last active August 6, 2023 12:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmmarmol/217ef9f7053a317b757c9a48f96099a9 to your computer and use it in GitHub Desktop.
Save dmmarmol/217ef9f7053a317b757c9a48f96099a9 to your computer and use it in GitHub Desktop.
Simple Batch file for running MongoDB on a windows computer
if not exist "C:\mongodb\data\db\" mkdir C:\mongodb\data\db
if not exist "C:\mongodb\data\log\" mkdir C:\mongodb\data\log
@echo off
:: Update the 3.4 if you have another version
cd C:\Program Files\MongoDB\Server\3.4\bin
::set default port variable
set port=27017
:: add this line at the end of the ~mongod.exe to write the log on a separated file
:: --logpath C:\mongodb\data\log\mongo.log
start cmd /k mongod.exe --port %port% --dbpath C:\mongodb\data\db
start cmd /k mongo.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment