Location of the mongodb database on mac
If MongoDB is installed on macOS via Homebrew, the default data directory depends on the type of processor in the system.
Intel Processor | Apple M1 Processor | |
---|---|---|
Data Directory | /usr/local/var/mongodb |
/opt/homebrew/var/mongodb |
Configuration file | /usr/local/etc/mongod.conf |
/opt/homebrew/etc/mongod.conf |
Log directory | /usr/local/var/log/mongodb |
/opt/homebrew/var/log/mongodb |
Run brew --prefix
to see where Homebrew installed these files.
See the MongoDB "Install on macOS" documentation for additional details.
Thanks @Mark, I keep forgetting this again and again. After installing MongoDB with Homebrew:
- The databases are stored in the /usr/local/var/mongodb/ directory
- The mongod.conf file is here: /usr/local/etc/mongod.conf
- The mongo logs can be found at /usr/local/var/log/mongodb/
- The mongo binaries are here: /usr/local/Cellar/mongodb/[version]/bin
The default data directory for MongoDB is /data/db
.
This can be overridden by a dbpath
option specified on the command line or in a configuration file.
If you install MongoDB via a package manager such as Homebrew or MacPorts these installs typically create a default data directory other than /data/db and set the dbpath in a configuration file.
If a dbpath was provided to mongod
on startup you can check the value in the mongo
shell:
db.serverCmdLineOpts()
You would see a value like:
"parsed" : {
"dbpath" : "/usr/local/data"
},