For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Default Data and Log Directory Paths

MongoDB Enterprise and Community packages ship with a configuration file that sets the default directories for data and logging. This configuration file is loaded by default when you start mongod as a service.

By default on Linux, MongoDB runs using the mongod user account. If you change the user that runs the MongoDB process, you must also modify the permissions to the data and log directories to give this user access to these directories.

Official MongoDB packages include a configuration file.

These settings, such as the data directory and log directory specifications, take effect upon startup. That is, if you change the configuration file while the MongoDB instance is running, you must restart the instance for the changes to take effect.

Select your operating system to view the default directories for MongoDB.

Packages that install MongoDB on Linux-based operating systems place the configuration file at /etc/mongod.conf. When you start MongoDB through systemd, it automatically loads this configuration.

The configuration file sets the data directory to different paths, depending on your distribution:

Distributions
Path

RHEL, SUSE, and Amazon Linux

/var/lib/mongo

Debian and Ubuntu

/var/lib/mongodb

To change this default:

  • Update the storage.dbPath setting in the configuration file to change the data directory used by the service.

  • Run mongod with the --dbPath option to change the path when manually starting MongoDB.

The configuration file sets the log directory to /var/log/mongodb. To change this default:

  • Update the systemLog.path setting in the configuration file to change the log directory used by the service.

  • Run mongod with the --logpath option to change the path when manually starting MongoDB.

Packages that install MongoDB on Windows place the configuration file at <install directory>\bin\mongod.cfg. When you start MongoDB as a Windows service, the service automatically loads this configuration.

The configuration file sets the data directory to C:\Program Files\MongoDB\Server\9.0\data. To change this default:

  • Update the storage.dbPath setting in the configuration file to change the data directory used by the service.

  • Run mongod with the --dbPath option to change the path when manually starting MongoDB.

The configuration file sets the log directory to C:\Program Files\MongoDB\Server\9.0\log\mongod.log. To change this default:

  • Update the systemLog.path setting in the configuration file to change the log directory used by the service.

  • Run mongod with the --logpath option to change the path when manually starting MongoDB.

Formulae that install MongoDB on macOS using Homebrew use a configuration file. When you start MongoDB as a Homebrew service, it automatically loads this configuration.

The specific default paths used by MongoDB depend on whether you installed the Homebrew formulae on an Apple Silicon- or Intel-based macOS system.

The configuration file is at /opt/homebrew/etc/mongod.conf.

The default data directory is /opt/homebrew/var/mongodb.

To change this default:

  • Update the storage.dbPath setting in the configuration file to change the data directory used by the service.

  • Run mongod with the --dbPath option to change the path when manually starting MongoDB.

The default log directory is /opt/homebrew/var/log/mongodb.

To change this default:

  • Update the systemLog.path setting in the configuration file to change the log directory used by the service.

  • Run mongod with the --logpath option to change the path when manually starting MongoDB.