How to use 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
This guide provides step-by-step instructions for installing and using MySQL on macOS. It’s tailored for engineers looking to get MySQL up and running quickly and efficiently.
If you don’t have Homebrew installed, you’ll want to start there:
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
Once Homebrew is installed:
brew update
brew install mysql
# To start MySQL
brew services start mysql
# To stop MySQL
brew services stop mysql
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
By default, MySQL creates a user root with no password. You can connect to the MySQL server with the following command:
mysql -uroot
If you’ve set a password for root (recommended):
mysql -uroot -p
It will then prompt you for the password.
Once connected, here are a few basic commands to get started:
SHOW DATABASES;CREATE DATABASE dbname;USE dbname;SHOW TABLES;DESCRIBE tablename;Remember to end each command with a semicolon (;).
brew remove mysql
brew cleanup
Stop the MySQL server:
sudo /usr/local/mysql/support-files/mysql.server stop
Remove MySQL files:
sudo rm -rf /usr/local/mysql
sudo rm -rf /usr/local/mysql-*
sudo rm -rf /Library/StartupItems/MySQLCOM
Remove MySQL preferences:
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
Remove the MySQL user and group (be cautious with this step):
sudo dscl . -delete /Users/mysql
sudo dscl . -delete /Groups/mysql
That’s it! You should now have a solid foundation for using MySQL on your Mac. As always, consult the official MySQL documentation for deeper dives into specific topics and advanced configurations.
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.