Everywhere All articles Download Buy — $19

Where apps hide your files

Where MySQL stores its databases

Updated 2026-10-28 · 6 min read

MySQL on a Mac keeps every database in one data directory, and where that is depends on whether you used Oracle's installer or Homebrew. This shows both, how to confirm it from the server, and how to back it up or shrink it safely.

The paths

Official installer (DMG):    /usr/local/mysql/data
Homebrew, Apple silicon:     /opt/homebrew/var/mysql
Homebrew, Intel:             /usr/local/var/mysql

The /usr/local path was verified with an Intel build of Homebrew MySQL 8.3 running under Rosetta on an Apple silicon Mac: /usr/local/var/mysql held the system files and one folder per database, and Homebrew's launch agent starts the server with --datadir=/usr/local/var/mysql. A native Apple silicon install uses the same layout under /opt/homebrew. Oracle's installer puts its files in a folder under /usr/local named after the version and platform (such as mysql-8.4.13-macos10.15-x86_64), with a /usr/local/mysql symlink pointing at it, and the data lives in data inside that.

If MySQL is running, confirm the folder from the server rather than trusting a guide:

mysql -u root -p -e "SELECT @@datadir;"

You will be asked for the MySQL root password (a fresh Homebrew install has none, so press Return). The reply is the data directory for that server, whatever installed it.

What is inside

ItemWhat it is
A folder per databaseEach schema you created is a folder, such as shop or blog
mysql/, mysql.ibd, sys/, performance_schema/MySQL's own system schemas and data dictionary; leave alone
ibdata1The InnoDB system tablespace (change buffer and any tables stored there); it never shrinks
undo_001, undo_002Undo tablespaces, separate from ibdata1 in MySQL 8
#innodb_redo/, #innodb_temp/Redo log (this folder name from MySQL 8.0.30) and temporary tablespaces
binlog.000001 and so onBinary logs, plus binlog.index
*.pemTLS and RSA keys and certificates MySQL generates for itself; the -key files are private
auto.cnfThe server's unique ID
<hostname>.errThe error log in a Homebrew install

With the default InnoDB engine, each table inside a database folder is an .ibd file. These are not usable alone. Copying a single .ibd into another server does not work without MySQL's tablespace import steps.

Logs and the config file

The Homebrew error log is the .err file in the data directory, named after your Mac's hostname, so a new one starts whenever the hostname changes; the test Mac had ten of them. Oracle's installer logs to /usr/local/mysql/data/mysqld.local.err.

Oracle's documentation says the macOS installer does not create a my.cnf. Homebrew creates one at /opt/homebrew/etc/my.cnf (Apple silicon) or /usr/local/etc/my.cnf (Intel), which only sets bind-address = 127.0.0.1 (and the same for the X Protocol). MySQL also reads /etc/my.cnf, /etc/mysql/my.cnf and ~/.my.cnf if they exist. List what your server reads with mysqld --verbose --help | grep -A1 "Default options".

Back up with mysqldump

Copying the data folder from a live server gives a damaged backup. The supported tool is a dump:

mysqldump -u root -p --all-databases > all-databases.sql
mysqldump -u root -p shop > shop.sql

Restore with mysql -u root -p < all-databases.sql. A dump moves cleanly between versions and between Intel and Apple silicon Macs, which a raw copy of the folder does not always do. Keep the dump file private: it contains your data, and a full dump includes the mysql schema with user password hashes.

Space and what is safe to remove

Check how big it is with du -sh on the data directory (the installer's server runs as the _mysql user, so reading its folder usually needs sudo). On the Mac used for checking, a development install was about 218 MB.

What grows fastest is rarely the data. Binary logs pile up because MySQL 8 enables them by default and keeps them for 30 days (the binlog_expire_logs_seconds setting). On a development machine they can be cleared from inside MySQL, which is safer than deleting files:

PURGE BINARY LOGS BEFORE NOW();

Or add skip-log-bin under [mysqld] in my.cnf to stop making them. Use SQL such as DROP DATABASE name; to remove a database you no longer need rather than deleting its folder. Do not delete ibdata1, the undo files, #innodb_redo or the mysql folder: the server will fail to start, and the loss is permanent.

Stop MySQL before moving or copying anything: brew services stop mysql for Homebrew (use the formula name you installed, such as mysql@8.4), or the MySQL pane in System Settings for Oracle's installer. That pane also has an Initialize Database button, which Oracle's documentation says recreates the data directory, so never press it on a server you care about.

Moving to a new Mac or changing the location

For a new Mac, dump and restore as above. Relocating the data directory in place is fiddly, because both Homebrew's launch agent and the installer's launch daemon (/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist) pass --datadir on the command line, which overrides any datadir line in my.cnf. You would have to stop the server, move the folder, keep its owner (your account for Homebrew, _mysql for the installer) and change the path in that launch file. A fresh install in the default place plus a dump and restore is usually less trouble. If you do move it, keep it out of Desktop, Documents and Downloads, which macOS privacy controls can block background services from reading.

Upgrading to a newer version upgrades the data dictionary and system tables in place the first time the new server starts. Oracle's documentation supports going back to an older release series only by dump and load (or replication), not by starting the old server on the same folder, so dump before you upgrade.

Finding the files by name

The data folders sit inside /usr or /opt, which Finder hides, so you will not stumble on them by browsing. In Everywhere, typing ibdata1 lists the data directory of every MySQL install on the Mac at once, an old Homebrew one or a MAMP copy included, and typing .err or binlog shows the log files taking space. ⌘↵ reveals the folder in Finder. It reads names only, so it will not tell you what is stored in a table.

Common questions

Where is the MySQL data directory on a Mac?

For Oracle's installer it is /usr/local/mysql/data. With Homebrew it is /opt/homebrew/var/mysql on Apple silicon or /usr/local/var/mysql on Intel. SELECT @@datadir; gives the exact path.

Can I back up MySQL by copying the data folder?

Only with the server fully stopped, and even then it suits the same version only. mysqldump is the dependable way and works across versions and Macs.

Where is my.cnf on a Mac?

Oracle's installer does not create one. Homebrew creates /opt/homebrew/etc/my.cnf (Apple silicon) or /usr/local/etc/my.cnf (Intel). MySQL also reads /etc/my.cnf, /etc/mysql/my.cnf and ~/.my.cnf if present.

Why is my MySQL folder so big?

Usually binary logs (binlog.NNNNNN), which MySQL 8 keeps for 30 days by default, and the InnoDB files. PURGE BINARY LOGS clears old logs from inside MySQL without touching the databases.

Find any file before you finish typing

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

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support