I have tried to install and uninstall 3-4 times to identify my problems. Every time after successful installation of mongoDB, it stops service and gets me an error when I try to connect from the local server[connect ECONNREFUSED 127.0.0.1:27017] and I get a message from windows windows security alerts after this setting, MongoDB is removed from services.msc. I have checked both options one by one and also checked both of these from the control panel but still every time my problem is same.
Update: I have tried to set path also as variable.
The .msi does not work so well. Better create a config file like this
# Where and how to store data.
storage:
dbPath: C:\MongoDB\data\mongod
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: C:\MongoDB\log\mongod.log
# network interfaces
net:
port: 27017
bindIpAll: true
processManagement:
windowsService:
serviceName: MongoDB
displayName: MongoDB
description: MongoDB Server - Standalone DB
security:
authorization: enabled
and then install the service like this
mongod.exe --config "c:\MongoDB\config\mongod.cfg" --install
You need to run this command as Administrator. Then the service should start automatically at boot time.