Moving PostgreSQL and MySQL data off a Mac's internal SSD: stop, copy, point, verify
If you develop on a Mac, a local PostgreSQL or MySQL server quietly keeps every test database, every imported dump and every write-ahead log you ever made. On our own dev Mac, three Homebrew data folders added up to about 900 MB, and that was a light one: imported production dumps easily reach tens of gigabytes.
You can move that data to an external drive. The one rule that matters: <b>never copy or move a data directory while the server is running.</b> PostgreSQL's manual is blunt about it: the server must be shut down to get a usable copy, and even blocking connections isn't enough.
Step 1: find the real data directory
Don't guess the path. Ask the running server, then measure:
- Each PostgreSQL major version has its own folder (
postgresql@16,postgresql@18...). An old one left over from an upgrade is often the biggest win, but check withbrew services listwhich ones still run before you touch anything. - Postgres.app, Docker volumes and MySQL's own installer keep data elsewhere. The
SHOW/SELECTanswer is the truth.
Step 2: make a backup you can restore from
The file copy in step 4 is the move; this dump is your insurance if the copy or the drive fails.
Step 3: prepare the external drive
- Format it as APFS (exFAT doesn't keep Unix owners and permissions, which both servers need).
- In Finder, select the drive, File > Get Info, and make sure Ignore ownership on this volume is off. PostgreSQL refuses to start if its data folder isn't owned by the user that runs it.
- Use a drive that stays plugged in. If it's missing when the server starts, the server will fail to start (which is better than starting on an empty folder, but still annoying).
- Check Time Machine's options: external drives are often on the exclude list, so the moved data may not be backed up unless you add it.
Step 4: stop, copy, point (PostgreSQL)
This keeps Homebrew's service working by leaving a symbolic link at the old path. The old folder is renamed, not deleted, so you can go back.
Step 4: stop, copy, point (MySQL)
MySQL has a setting for this, so no link is needed: change <code>datadir</code> in the config file Homebrew's MySQL reads (<code>/opt/homebrew/etc/my.cnf</code>).
Step 5: verify before you free any space
- Check the server is up:
pg_isreadyormysqladmin -u root -p status. - Ask it where it is:
SHOW data_directory;/SELECT @@datadir;. - Open a database you care about and count rows in a big table. Run your app's test suite against it.
- Look at the log if it didn't start (
brew services info $Vshows the log path).Operation not permittedorwrong ownershipmeans a permission or privacy setting on the drive; roll back and fix that first.
Rolling back
Only when everything has worked for a week or so, delete the <code>.internal-old</code> folder. That's the moment the internal SSD actually gets the space back.
Zofle, our free Mac app, measures big app folders like these and shows what each one is before you remove anything, so the cleanup goes through the app that owns the data first.
Download Zofle for MacRelated
Sources
- PostgreSQL documentation: Database File Layout (PGDATA).
- PostgreSQL documentation: File System Level Backup.
- PostgreSQL documentation: pg_dumpall.
- MySQL 8.4 Reference Manual: datadir system variable.
- MySQL 8.4 Reference Manual: mysqldump.
- Folder sizes read with du on a Homebrew dev Mac in November 2026. The move steps follow the manuals' stop-the-server rule; paths are Homebrew defaults on Apple silicon and need adjusting for other installs.
Zofle Pro news
People signing up now will get Zofle Pro, with more features, for free when we launch it.