Where are MongoDB database and config stored

There is no need to introduce such popular document-oriented database as MongoDB.
So let’s go straight to the point.

Default configuration file location:

# on Linux, macOS (installed via MacPorts) or RHEL / CentOS yum

# on macOS via Homebrew

# on Windows

You can override default configuration path by passing –config or -f parameter at startup of mongod.

$ mongod --config /private/etc/mongod.conf
# or
$ mongod -f /private/etc/mongod.conf

Which could be especially useful if you want to run several MongoDB instances within a single server.

Default database location – where data files are actually stored:

# RHEL / CentOS yum or Ubuntu / Debian apt

# on macOS via MacPorts

# on macOS brew

It is set with dbPath parameter in your config file’s storage section:

   dbPath: /etc/mongo/data/db

How to get config file location of running MongoDB instance

Simply query active processes containing mongo in look at options.
If –config or -f are not set – then look for default configuration path described above.

$ ps ax | grep "mongo"
13407 ?        Sl   1163:17 /usr/bin/mongod -f /etc/mongod.conf

Leave a Reply