Specify dbpath when MongoDB starts.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.