What is the default database path for MongoDB?

前端 未结 5 627
[愿得一人]
[愿得一人] 2020-11-29 01:29

I got an error about dbpath (/data/db/) does not exist, but /etc/mongodb.conf named it dbpath = /var/lib/mongodb. So, which is the de

5条回答
  •  执念已碎
    2020-11-29 01:43

    The Windows x64 installer shows the a path in the installer UI/wizard.

    You can confirm which path it used later, by opening your mongod.cfg file. My mongod.cfg was located here C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg (change for your version of MongoDB!

    When I opened my mongd.cfg I found this line, showing the default db path:

    dbPath: C:\Program Files\MongoDB\Server\4.0\data
    

    However, this caused an error when trying to run mongod, which was still expecting to find C:\data\db:

    2019-05-05T09:32:36.084-0700 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating

    You could pass mongod a --dbpath=... parameter. In my case:

    mongod --dbpath="C:\Program Files\MongoDB\Server\4.0\data"
    

提交回复
热议问题