MongoDB 3.0 Windows Service Start : System Error 2 has occured

£可爱£侵袭症+ 提交于 2020-01-01 03:02:42

问题


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.


回答1:


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.




回答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




回答3:


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


来源:https://stackoverflow.com/questions/28886119/mongodb-3-0-windows-service-start-system-error-2-has-occured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!