Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mawiseman/27580c0dd410be9f0ff816ec4d41c65a to your computer and use it in GitHub Desktop.
Save mawiseman/27580c0dd410be9f0ff816ec4d41c65a to your computer and use it in GitHub Desktop.
ECHO MongoDB Installation
@ECHO OFF
set mongoVersion=3.2
set mongoServiceName="MongoDB-%mongoVersion%"
set mongoDBFolder=C:\Data\MongoDB\%mongoVersion%
set mongoDBDataFolder=%mongoDBFolder%\Data
set mongoDBLogsFolder=%mongoDBFolder%\Logs
set mongoDBMongoD="C:\Program Files\MongoDB\Server\%mongoVersion%\bin\mongod.exe"
set mongoDBMongo="C:\Program Files\MongoDB\Server\%mongoVersion%\bin\mongo.exe"
set mongoDBIP="127.0.0.1"
set mongoDBPort="27017"
@ECHO ON
ECHO MongoFolder: Creating
mkdir %mongoDBFolder%
mkdir %mongoDBDataFolder%
mkdir %mongoDBLogsFolder%
ECHO MongoFolder: Created / Finished
pause
ECHO Stop and Remove Old Service
%mongoDBMongoD% --remove --serviceName %mongoServiceName%
ECHO Stopped and Removed
pause
ECHO MongoSetup: Configuring installation
%mongoDBMongoD% --logpath %mongoDBLogsFolder%\Mongo.log --dbpath %mongoDBDataFolder% --directoryperdb --port %mongoDBPort% --logappend --quiet --noauth --install --serviceName %mongoServiceName% --serviceDisplayName %mongoServiceName%
ECHO MongoSetup: Finished installation
pause
ECHO MongoService: Starting Service
net start %mongoServiceName%
ECHO MongoService: Started
pause
ECHO Checking Status Output
%mongoDBMongo% %mongoDBIP%:%mongoDBPort%/admin
db.serverStatus()
exit
ECHO Finished Setting Up Replication Sets
pause
ECHO Running Browser to Confirm Installation
start http://%mongoDBIP%:%mongoDBPort%/
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment