I build WordPress websites in a local development environment powered by Laravel Valet. I’ve been using this setup for a couple years now. It’s fast, light weight, and it’s been awesome – until it isn’t. 😉
This has happened to me twice in the last 6 months.
I run an alias for a few homebrew update commands…
brew update; brew upgrade; brew cleanup; brew doctor;
At the end of the summary of what’s been updated, sometimes a little advisory pops up and advises me to run brew prune to remove unneeded files.
All of the sudden, my local development sites start failing to find their associated local database.
The first time it happened, I couldn’t find a good solution and ended up losing some data and starting over–completely rebuilding my development environment.
When it happened again yesterday…
I hunted for a solution for a little longer. I did not want go through that again.
Turns out there’s a really simple fix.
Apparently, when brew prune gets run, a temp directory gets removed. I figured I’d write this down to save myself a headache next time this happens.
Recreating that directory and restarting MariaDB or MySQL will restore access to your local databases.
mkdir /usr/local/etc/my.cnf.d brew services restart mariadb