Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB 3.0 Windows Service Start : System Error 2 has occured

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.

like image 719
Roger Layton Avatar asked Mar 05 '15 19:03

Roger Layton


2 Answers

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.

like image 78
JenkinsY Avatar answered Nov 10 '22 07:11

JenkinsY


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

like image 27
Mehmet Topçu Avatar answered Nov 10 '22 07:11

Mehmet Topçu