'What is the difference between mongod and Service of mongodb run in windows services

Recently I started learning Mongodb. After the installation I ran the > mongo command and without starting the daemon ie the mongod and even without starting the the daemon it ran perfectly and i was able to do all the CRUD operations

Later I tried running mongod first and then mongo command and was able to perform all the same operations

So my question is that how come I was able to run mongo without starting the daemon ??



Solution 1:[1]

There is generally two options to start single mongodb database server:

1. As a console application

1.1. mongod --config mongod.conf

Via this way the configuration parameters are stored in the mongod.conf file

1.2. mongod --port 2000 --dbpath /data/

Via this way you provide all necessary configurations in command line

2. As operating system service or daemon

2.1. Via configuration parameter in the mongod.conf file:

    processManagement:
      fork: true

2.2. Via the operating system services configurations.

This one depends on operating system

The difference is that when you start the mongod as console application you can see the log messages directly in the screen and you can stop it any time pressing [CTRL]+[C] , this option is preferred for testing , but if you want to run the mongodb permanently you will prefer to execute it as a service.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marc_s