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 /etc/mongod.conf # on macOS via Homebrew /usr/local/etc/mongod.conf # on Windows %install_directory%/bin/mongod.cfg
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 /var/lib/mongo # on macOS via MacPorts /etc/mongo/data/db # on macOS brew /usr/local/var/mongodb
It is set with dbPath parameter in your config file’s storage section:
storage: 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