What is the default database path for MongoDB?

前端 未结 5 635
[愿得一人]
[愿得一人] 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 default dbpath for mongodb is /data/db.

    There is no default config file, so you will either need to specify this when starting mongod with:

     mongod --config /etc/mongodb.conf
    

    .. or use a packaged install of MongoDB (such as for Redhat or Debian/Ubuntu) which will include a config file path in the service definition.

    Note: to check the dbpath and command-line options for a running mongod, connect via the mongo shell and run:

    db.serverCmdLineOpts()
    

    In particular, if a custom dbpath is set it will be the value of:

    db.serverCmdLineOpts().parsed.dbpath           // MongoDB 2.4 and older
    db.serverCmdLineOpts().parsed.storage.dbPath   // MongoDB 2.6+
    

提交回复
热议问题