LinuxmacOSWindows

Where Is the MongoDB Data Directory?

MongoDB data files live wherever dbPath points. The package defaults on Linux, macOS, and Windows, plus the config files.

Last updated

MongoDB stores data wherever the storage.dbPath setting points. A bare mongod run defaults to /data/db, or C:\data\db when started from C: on Windows. Package installs change that to distro specific paths.

On Ubuntu and Debian the shipped /etc/mongod.conf sets /var/lib/mongodb. RHEL and SUSE use /var/lib/mongo. Homebrew on macOS uses /usr/local/var/mongodb. The Windows MSI installer lets you pick the folder and records it in mongod.cfg.

Where MongoDB stores this, by platform

Linux
/var/lib/mongodb

Set by /etc/mongod.conf on apt installs (/var/lib/mongodb) and yum installs (/var/lib/mongo). The mongod user needs read and write access here.

macOS
/usr/local/var/mongodb

Homebrew default from /opt/homebrew/etc/mongod.conf on Apple Silicon or /usr/local/etc/mongod.conf on Intel. Intel era guides often show /usr/local/var/mongodb.

Windows
C:\data\db

Bare mongod defaults to C:\data\db. The MSI installer default config lives alongside the binaries as <install-dir>\bin\mongod.cfg and usually points at C:\Program Files\MongoDB\Server\<version>\data\db.

Frequently asked questions

how do i find my actual mongodb data folder

Check the storage.dbPath value in your mongod config file (/etc/mongod.conf on Linux package installs). That single setting decides the real location. The command line --dbpath flag overrides it for that run.

can i back up mongodb by copying files

Stop mongod first, then copy the whole dbPath directory with permissions intact. Copying individual collection files while the server runs gives you a corrupt backup. mongodump is the safer route for logical backups.

Notice an outdated path? Let us know.