[MongoDB] Check the dbpath where database files are stored

Tadashi Shigeoka ·  Mon, August 31, 2015

The dbpath where MongoDB database files are stored can be checked from the execution result of db.serverCmdLineOpts().

MongoDB | モンゴディービー

Query to check dbpath

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

(Example) Execution result of db.serverCmdLineOpts()

Besides dbPath, you can also check the output destination of config files and systemLog files.

> db.serverCmdLineOpts()
{
  "argv" : [
    "/usr/local/opt/mongodb/bin/mongod",
    "--config",
    "/usr/local/etc/mongod.conf"
  ],
  "parsed" : {
    "config" : "/usr/local/etc/mongod.conf",
    "net" : {
      "bindIp" : "127.0.0.1"
    },
    "storage" : {
      "dbPath" : "/usr/local/var/mongodb"
    },
    "systemLog" : {
      "destination" : "file",
      "logAppend" : true,
      "path" : "/usr/local/var/log/mongodb/mongo.log"
    }
  },
  "ok" : 1
}

That’s all.

Reference Information

That’s all from the Gemba.