Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location of the mongodb database on mac

I am kind of new to mac as well as mongodb.

I have a weird doubt, accessing the database created using mongodb on mac?

I know, in windows there is a folder called c:\data\db, where my database files are stored.

How and where in mac, the database is stored.

I remember doing something like

sudo mkdir -p /data/db sudo chown `id -u` /data/db 

to create such a folder on mac, but I didn't find any database file in this folder, though i created a database.

Where are the database files saved on mac?

Any help would be really appreciated.

like image 343
Spaniard89 Avatar asked Dec 11 '12 20:12

Spaniard89


People also ask

Where is my MongoDB database located?

The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt.


2 Answers

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.

like image 193
Mark Edington Avatar answered Sep 29 '22 02:09

Mark Edington


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
like image 22
simonbogarde Avatar answered Sep 29 '22 04:09

simonbogarde