MongoDB: Change database location (Windows)

Source: Internet
Author: User

The default database directory for MongoDB in Windows is C:\Data. If you run Mongod.exe directly without the directory, the following error is reported:

In some cases, we do not want to put MongoDB database on the C disk, there are two ways to switch the database directory.

1. Command mode

Start by creating a database directory, such as D:\data. Then run the command

Mongod–dbpath D:\data

2. How to configure Files

Create a profile anywhere, such as a file named Master.cfg, in the c:\mongodb\conf directory, with the contents of Dbpath=d:\data. Then run the command

Mongod–config c:\mongodb\conf\master.cfg

The result of the final output will be similar to that for the database switchover success:

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.