We can also configure MongoDB to run as a windows service .
mongod.exe added support for running as a Windows service in version 2.0, and mongos.exe added support for running as a Windows Service in version 2.1.1.
Step 1 : Create configuration file mongod.cfg .
echo logpath=C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg
A new file mongod.cfg will be created at location C:\mongodb. This file contains an entry logpath which tells mongodb to save all logging information in the specified file mongo.log
Step 2 : Install MongoDB as a service .
Execute following command in command prompt :
mongod --config C:\mongodb\mongod.cfg --install
A new windows service will be created .
Step 3 : Start Mongo Service
Execute following command in command prompt :
net start MongoDB
Other Options :
1 . Stopping MongoDB Service :
net stop MongoDB
2 . Removing MongoDb service :
mongod.exe --remove