How to reinstall MySQL on Mac
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Robert Cooper
Robert Cooper Senior Engineer at Basedash
· January 31, 2025
Reinstalling MySQL on a Mac can be a relatively straightforward process. This guide is tailored for engineers who want to get the job done without the fluff.
Before any significant software change, it’s a good practice to backup your data.
mysqldump -u [username] -p --all-databases > backup.sql
Replace [username] with your MySQL username.
If MySQL is running, you’ll want to stop it:
sudo mysql.server stop
Remove the MySQL software:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/var/mysql
sudo rm -rf /usr/local/mysql*
If you’ve installed the MySQL Preference Pane, you should also remove it:
sudo rm -rf /Library/PreferencePanes/My*
Clean up any lingering items:
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Visit the official MySQL website and download the version for macOS: MySQL Downloads
Open the downloaded .dmg file and follow the installation instructions. Generally, it’s a matter of dragging and dropping the MySQL icon into your Applications folder.
To make sure you can run MySQL commands from the terminal without specifying the full path, add this to your .bash_profile, .bashrc, or .zshrc (depending on your shell):
export PATH=${PATH}:/usr/local/mysql/bin
Then, load your updated profile:
source ~/.bash_profile # or ~/.bashrc or ~/.zshrc
mysql -u [username] -p < backup.sql
Replace [username] with your MySQL username.
To ensure your MySQL server is secure:
sudo mysql_secure_installation
Follow the prompts to set a root password and make any other recommended security changes.
You’ve successfully reinstalled MySQL on your Mac. Remember to always backup your data before making significant changes, and ensure that any configurations or custom settings are documented so you can recreate them if needed. Happy querying!
Written by
Senior Engineer at Basedash
Robert Cooper is a senior engineer at Basedash who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.