通过批处理 安装 mongodb和设置身份验证
set installpath=%~1set installpath2=%installpath:\=/%
rem Create installation directory
mkdir "%installpath%"
del "%installpath%\mongod.cfg"
echo systemLog:>>"%installpath%\mongod.cfg"
echo destination: file>>"%installpath%\mongod.cfg"
echo path: "%installpath2%/logs/mongodb.log">>"%installpath%\mongod.cfg"
echo storage:>>%installpath%\mongod.cfg
echo dbPath: "%installpath2%/db">>"%installpath%\mongod.cfg"
echo net:>>"%installpath%\mongod.cfg"
echo http:>>"%installpath%\mongod.cfg"
echo enabled: true>>"%installpath%\mongod.cfg"
echo RESTInterfaceEnabled: true>>"%installpath%\mongod.cfg"
rem install mongodb
msiexec /x mongodb.msi /qn
mongodb.msi /qn INSTALLLOCATION="%installpath%" ADDLOCAL="all"
mkdir "%installpath%"\db
mkdir "%installpath%"\logs
rem create service
"%installpath%\bin\mongod.exe" --auth --config "%installpath%\mongod.cfg" --smallfiles -install
rem start service
net start MongoDB
"%installpath%\bin\mongo.exe" 127.0.0.1:27017/admin --quiet SetAuth.js
net stop MongoDB
net start MongoDB
pause
页:
[1]