Running mongodb by command is easy but we required always to open command and run mongod and remain open it side by side while working on mongodb.
In windows to run mongodb server automatically we need to install mongodb server as windows service.
To install mongodb as windows service first we need to install mongodb in windows then add environment variable to mongodb install path and then check either mongodb is workable or not in windows by typing command mongod in one command prompt and check it by running command mongo on another command prompt. If this completed successfully then we are moving to next step to install mongodb as windows service.
Open command prompt with administrator previdlege.
then type command
mongod --dbpath "c:\data\db" --logpath "c:\data\log.txt" --install --serviceName "mongoDB"
to install mongodb service