Monday, June 13, 2016

Run MongoDB as a service

Following command can be used to run mongo db as service.

mongod.exe --install --dbpath "c:\mongo\data\db" --logpath "c:\mongo\data\log"

You can also set dbpath & logpath in "mongod.cfg" file and run the command as follows.

mongod.exe --install --config "c:\mongo\mongod.cfg"

Sample mongod.cfg

systemLog:
    destination: file
    path: C:\Program Files\MongoDB\Server\3.2\data\log\mongod.log
storage:
    dbPath: C:\Program Files\MongoDB\Server\3.2\data\db

In Windows, you can stop service in services management window. Run/Services

In Linux, ps -ef|grep mongo then kill -9 process_id

No comments:

Post a Comment