How to install MySQL on Mac
Homebrew is quickest. Oracle's DMG installer adds a System Settings pane if you prefer that.
Option 1: Homebrew
-
Install Homebrew from brew.sh if needed.
-
Install and start MySQL:
brew install mysql brew services start mysql -
Set a root password and remove test defaults:
mysql_secure_installation -
Connect:
mysql -u root -p
Want MariaDB instead? Run brew install mariadb and brew services start mariadb. Don’t run both on port 3306 at once.
Option 2: Oracle’s installer
- Download the macOS DMG for your chip (ARM for Apple silicon, x86 for Intel) from dev.mysql.com.
- Run the installer. It asks you to set the root password.
- Start and stop the server from the MySQL pane in System Settings.
Create a database and a user
CREATE DATABASE myapp;
CREATE USER 'myapp'@'localhost' IDENTIFIED BY 'choose-a-password';
GRANT ALL PRIVILEGES ON myapp.* TO 'myapp'@'localhost';
If a GUI client later gets “Access denied” for this user over 127.0.0.1, create the same user for 'myapp'@'127.0.0.1' and grant it the same privileges.
Open it in a GUI
In Gadwal, add a MySQL connection with host 127.0.0.1, port 3306, and your user and password. Use 127.0.0.1 rather than a socket: App Store apps are sandboxed and can’t use Unix sockets. MySQL 8’s default caching_sha2_password login works over plain TCP and TLS.
Stop or remove
brew services stop mysql
brew uninstall mysql
Data stays in /opt/homebrew/var/mysql until you delete it.