Update: 2013-7-12
The mongodb-win32-x86_64-2.4.5 has fixed this error and does not need to add a backslash at the end of the command line.
========================================================== ====================
Version: mongodb-win32-x86_64-2.2.1
Today, when I installed MongoDB in windows, I found that it could not be started when I installed it as a Service. Later I went to Google to know that I needed to create a new X in the root directory: \ data \ dB \ folder.
But I don't want to put the data file here. Is there a way to specify dbpath when installing the service?
At the beginning, I thought this was not simple. I couldn't use the -- dbpath parameter. Run the following command to install it:
Mongod -- config c: \ MongoDB \ mongod. cfg -- dbpath c: \ MongoDB \ data \ dB \ -- install
Result service cannot be started. Check the log file. The original -- dbpath parameter will be followedAll charactersIt is regarded as a path, so when the service is started, it is considered that there is no path called "C: \ MongoDB \ data \ dB \ -- service", and the startup fails.
If the first attempt fails, change the parameter location and run the following command to install it:
Mongod -- install -- config c: \ MongoDB \ mongod. cfg -- dbpath c: \ MongoDB \ data \ dB \
OMG still cannot be started. Check the log file. The error message is "error: dbpath (C: \ MongoDB \ data \ DB") does not exist. ", note that the backslash after dB disappears. Check the executable file path in the service. The backslash is indeed used. Is this backslash treated as an escape character, lost During execution?
Run the following command to install the SDK:
Mongod -- install -- config c: \ MongoDB \ mongod. cfg -- dbpath c: \ MongoDB \ data \ DB
\\
Since a backslash does not work, I can write two.
Finally, the instance is started successfully.
Now, the data path of the MongoDB service can be randomly specified to the desired location.