MongoDB 3.0 Getting Started with Windows: System 2 Error

I downloaded the MSi MongoDB Windows program and successfully executed it.

The mongod.exe and mongo.exe batch files are executed.

The installation guide shows how to create a configuration file and then create a 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.

Then the service starts

 net start MongoDB 

but it gives an answer

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

The permission for those who need it is that the manual indicates the wrong default path for mongod.exe, which should be in the bin directory

 C:\mongodb\bin\mongod.exe 

So, although this is a question, I also solved it for the benefit of others who may have this problem.

Also, by default, MongoDB will be installed in C: \ Program Files on Windows, and you must use a custom installation to put it in C: \ mongodb.

+6
source share
3 answers

You may already have a service named "MongoDB" before installation and therefore it has not been installed successfully.

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

and then you can try to install the service again and run the net start MongoDB command. Now it should work.

+4
source

After installing mongodb in C:\mongodb you simply do:

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

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

 net start MongoDB 
0
source

I ran into this problem. And I decided, as shown below.

1) Create these folders

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

2) Run CMD as administrator

 C:\Windows\System32\cmd.exe 

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

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

4) This is important, I do not use sc.exe Define the log directory and db and install the 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

0
source

Source: https://habr.com/ru/post/983397/


All Articles