- 下载MongoDB安装文件,解压到D:\MongoDB;
- 运行脚本:
@echo off set mongobin=D:\MongoDB ::在mongodb文件夹下建立data,log文件夹
md %mongobin%\data
md %mongobin%\log cd %mongobin%\bin mongod --repair --dbpath "%mongobin%\data\db"
mongod --install --serviceName "MongoDBMaster" -serviceDisplayName "MongoDBr" --dbpath "%mongobin%\data\db" --logpath "%mongobin%\data\log\MongoDB.log" --master net start MongoDB @echo Install finish!
然后打开Service既可以看到名字叫“MongoDB”的服务.