How to setup MongoDB so it can run as Windows service?
相关问题
- MongoDB can not create unique sparse index (duplic
- Spring Data MongoDB - lazy access to some fields
- Golang mongodb aggregation
- Why does a windows service, hosting an NserviceBus
- How to convert from Timestamp to Mongo ObjectID
相关文章
- mongodb有没有什么办法禁止读取数据的时候进行缓存
- mongodb-aggregate聚合查询分组后如何获得多字段
- mongodb error: how do I make sure that your journa
- How to track MongoDB requests from a console appli
- XCopy or MOVE do not work when a WCF Service runs
- MongoError: cannot infer query fields to set, path
- Pymongo $in Query Not Working
- Problem installing windows service
This PowerShell Script Downloads and Installs MongoDB as Windows Service:
Run below in an administrative
cmd
This will remove the existing MongoDB service (if any).
Make sure that
C:\data\db
folder existsOpen services with:
Find MongoDB -> Right click -> Start
This answer is for those who have already installed mongo DB using MSI installer.
Let's say your default installed location is "C:\Program Files\MongoDB\Server\3.2\bin"
Steps to run mongo as a window service
cd C:\Program Files\MongoDB\Server\3.2\bin
(check path properly, as you may have a different version installed, and not 3.2).net start MongoDB
services.msc
and check if Mongo is running as a service.These are the steps to install MongoDB as Windows Service :
Create a log directory, e.g.
C:\MongoDB\log
Create a db directory, e.g.
C:\MongoDB\db
Prepare a configuration file with following lines
dbpath=C:\MongoDB\db
logpath=C:\MongoDB\log
Place the configuration file with name mongod.cfg in folder "C:\MongoDB\"
Following command will install the Windows Service on your
sc.exe create MongoDB binPath= "\"C:\MongoDB\Server\3.4\bin\mongod.exe\" --service --config=\"C:\MongoDB\mongod.cfg\" DisplayName= "MongoDB 3.4" start= "auto"
Once you run this command, you will get the
[SC] CreateService SUCCESS
Run following command on Command Prompt
net start MongoDB
not only
--install
,also need
--dbpath
and--logpath
and after reboot OS you need to delete "mongod.lock" manually