Skip to content

Instantly share code, notes, and snippets.

@lucascaton
Forked from tomas-stefano/reinstall.sh
Last active April 29, 2024 00:26
Show Gist options
  • Save lucascaton/3373792 to your computer and use it in GitHub Desktop.
Save lucascaton/3373792 to your computer and use it in GitHub Desktop.
Reinstalling MySQL 5.x on macOS via Homebrew
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql
brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.5.25a/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# Success! :-)
@lucascaton
Copy link
Author

lucascaton commented Apr 29, 2024

@MikKuba, @giovannievway, I had to uninstall it, delete all the data, and re-install it to get it working again 🙂

brew uninstall mysql@8.0
rm -rf /opt/homebrew/var/mysql
brew install mysql@8.0

Then, to check, I ran brew services list:

Name          Status     User       File
mysql@8.0     started    [myuser]   ~/Library/LaunchAgents/homebrew.mxcl.mysql@8.0.plist
# (others)

Hope this solves the issue for you too 🍀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment