8

I have downloaded the MongoDB Windows msi install and run this successfully.

The mongod.exe and mongo.exe command file executions work properly.

The installation manual shows how to create the configuration file, and then to create the Windows Server using the command

sc.exe create MongoDB binPath= "\"C:\mongodb\mongod.exe\" --service --config=\"C:\mongodb\mongod.cfg\""

This creates a SUCCESS response.

The service is then started

net start MongoDB

but this produces the response

System Error 2 has occurred.
The system cannot find the file specified.

The resolution, for those who need this, is that the manual indicates the incorrect default path for mongod.exe, which should be in the bin directory

C:\mongodb\bin\mongod.exe

Thus, whereas this is a question, I have also solved this for the benefit of others who may have this problem.

Also, by default, MongoDB will install in C:\Program Files in Windows, and you should use the custom install to put it into C:\mongodb.

Roger Layton
  • 1,573
  • 2
  • 13
  • 12
  • I disagree that this is a duplicate. My issue is that the default implementation and the manual are not in sync. This is not covered in the cited question or its answers. – Roger Layton Apr 30 '15 at 09:04

3 Answers3

4

It can be possible that you already have a service named "MongoDB" before your installation and thus it is not successfully installed.

try to remove the previous one using this: "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --remove

and then you can try install the service again and fire the net start MongoDB command. It should work now.

JenkinsY
  • 167
  • 3
  • 18
2

I have faced this problem.And I solved as below.

1) Create this folders

C:\data\db
C:\data\log

2)Run CMD as administrator

C:\Windows\System32\cmd.exe

3)If you've installed service , write below to cmd to remove

C:\Program Files\MongoDB\Server\3.6\bin> mongod.exe --remove

4) This is important , I don't use sc.exe Determine the log and db directory ,and instal service

C:\Program Files\MongoDB\Server\3.6\bin> mongod.exe --logpath c:\data\log\mongod.log --dbpath c:\data\db --directoryperdb --install

5)If success

net start MongoDB

enter image description here

Mehmet Topçu
  • 1
  • 1
  • 16
  • 31
0

After having installed mongodb in C:\mongodb you just do:

mongod --install --logpath C:\mongodb\logs\mongo.log

The path to the logfile must exist and it must be an absolute Windows path. Then you start the MongoDB service by typing:

net start MongoDB
Peter G.
  • 7,816
  • 20
  • 80
  • 154