Where apps hide your files
MongoDB stores your databases as WiredTiger files in a folder called the dbPath. With Homebrew it is a fixed folder under the Homebrew prefix, and one line of the config file confirms it.
/opt/homebrew/var/mongodb # Apple silicon
/usr/local/var/mongodb # Intel Mac
This is the storage.dbPath in the mongod.conf that MongoDB's own Homebrew formula writes (mongodb-community, from the mongodb/brew tap). The formula sets it to the var/mongodb folder under whichever Homebrew prefix installed it, and MongoDB's macOS install guide lists the same two paths. The Mac used for this guide has both Homebrew prefixes, with MongoDB installed under /usr/local, and its data files sit in /usr/local/var/mongodb.
Do not trust the default if you did anything unusual. Ask MongoDB's own config instead.
The config file sits under the same prefix:
/opt/homebrew/etc/mongod.conf # Apple silicon
/usr/local/etc/mongod.conf # Intel Mac
Print only the storage lines (the file can contain other settings, so do not paste it whole into a forum post):
grep -A1 '^storage' /opt/homebrew/etc/mongod.conf
Swap in /usr/local if that is your prefix. On the Mac used for this guide that shows dbPath: /usr/local/var/mongodb. The same file sets the log to var/log/mongodb/mongo.log under the prefix and binds the server to 127.0.0.1 and ::1. The formula writes mongod.conf only when none exists, so your edits survive upgrades.
If MongoDB is running, you can see exactly which config file it was started with:
ps aux | grep '[m]ongod'
Look for --config <path> on the command line. Homebrew's launch agent, homebrew.mxcl.mongodb-community.plist in ~/Library/LaunchAgents, passes that flag. Without --config or --dbpath, mongod uses its built-in default, /data/db. That folder does not exist on a Mac, and you cannot simply create it, because the system volume is read-only. MongoDB's guide uses a folder such as ~/data/db for manual runs instead.
| Item | What it is |
|---|---|
collection-<n>-<id>.wt | One WiredTiger file per collection |
index-<n>-<id>.wt | One file per index |
_mdb_catalog.wt | The catalogue that maps names to those files |
WiredTiger, WiredTiger.wt, WiredTiger.turtle, WiredTigerHS.wt | Storage engine metadata |
sizeStorer.wt, storage.bson | More engine bookkeeping |
journal/ | Write-ahead log |
diagnostic.data/ | Server metrics MongoDB collects for support |
mongod.lock, WiredTiger.lock | Lock files. On the Mac used for this guide, with the server stopped, mongod.lock is present but empty |
The file names carry numbers, not your collection names, so you cannot tell which file is which by looking, and nothing but mongod can read them as data.
See the total, and what takes it, with:
du -sh /usr/local/var/mongodb /usr/local/var/mongodb/diagnostic.data
Use your own path. On a development Mac the biggest item is often not your data. On the Mac used for this guide, diagnostic.data is 202 MB of a 203 MB folder. MongoDB's parameters reference caps that folder at 500 MB by default (the diagnosticDataCollectionDirectorySizeMB setting) and says the oldest files are deleted automatically, so the server keeps it in check; lower the setting if you want it smaller.
Safe to delete by hand: nothing in this folder. Removing a .wt file corrupts the database. Drop data from inside MongoDB with mongosh, or use the backup tools below.
The supported way is mongodump and mongorestore, from the mongodb-database-tools formula, which the MongoDB formula installs alongside the server by default. A dump is a portable folder of BSON files, and it works across Macs. Copying the data folder while MongoDB runs can produce a broken backup. If you want a file-level copy, stop the service first:
brew services stop mongodb-community
Use the formula name you installed (MongoDB's guide uses versioned names such as mongodb-community@8.0; brew services list shows yours). Copy the whole folder, then start the service again. Restore a file-level copy with the same MongoDB version, since MongoDB upgrades step through one major release at a time. Dump and restore avoids that problem.
Stop the service, move the folder's contents to the new place, edit storage.dbPath in mongod.conf to match, then start the service:
brew services start mongodb-community
The new folder must exist and be writable by your user. The config file is YAML, so keep the indentation. The Homebrew service runs as you, from a launch agent in your own Library, which is why the data folder is owned by your account.
The same mongod.conf sets systemLog.path with logAppend: true, so each start adds to the same log rather than replacing it. On the Mac used for this guide, mongo.log in /usr/local/var/log/mongodb is about 90 MB, larger than all of the databases combined. The folder also holds output.log, where the launch agent sends anything mongod prints to standard output and error.
Check the size with ls -lh on that folder. The log can hold query details, so do not paste it publicly. To clear space, stop the service, move mongo.log to the Trash in Finder, and start the service again; MongoDB creates a new file. Logs are the one thing in this part of the disk you can remove. Never touch the .wt files.
Homebrew's service runs mongod --config with the file above. If you instead start mongod by hand with --dbpath /some/folder, the data goes to that folder and the Homebrew folder stays untouched. This is the usual reason a database seems empty after switching how you start MongoDB: the server is looking at a different dbPath.
If you also use MongoDB Compass, its files are separate. On the Mac used for this guide they are in ~/Library/Application Support/MongoDB Compass (saved connections, preferences, recent queries and caches). That folder holds the GUI's settings, not your databases. The server's data is always in the dbPath.
/usr/local/var and /opt/homebrew/var are system-level folders that Spotlight and Finder searches leave out, and Finder hides /usr and /opt entirely. The files have no friendly names either, so a search for a collection name finds nothing.
If you are not sure which folder is live (an old Intel install and a newer Apple silicon one can both exist), type _mdb_catalog into Everywhere. Each MongoDB data directory has exactly one, so every hit is a dbPath, whether it sits under /usr/local/var, /opt/homebrew/var or a folder you passed with --dbpath. Press ⌘↵ to reveal it in Finder. It matches file names only, so it cannot show what is inside the database.
In /opt/homebrew/var/mongodb on Apple silicon and /usr/local/var/mongodb on Intel Macs, as set by storage.dbPath in mongod.conf.
It is /opt/homebrew/etc/mongod.conf on Apple silicon and /usr/local/etc/mongod.conf on Intel. Running ps aux | grep '[m]ongod' shows the --config path in use.
/data/db. It does not exist on a Mac and cannot be created on the read-only system volume, so pass --dbpath with a folder you own or use --config.
Only with the server stopped. For a safe, portable backup use mongodump and mongorestore.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised