Skip to content
Runbook

Install MySQL on macOS

Popular open source SQL relational database.

Databasesqlrdbmsrelationaldatabaseacid

Installation

Server (Homebrew) · Homebrew
brew install mysql

Installs the MySQL server and client (mysql, mysqld).

Verify the installation

Verify
mysql --version

Service

Start
brew services start mysql
Stop
brew services stop mysql
Status
brew services info mysql
Restart
brew services restart mysql

Important files

TypePathDescription
config/opt/homebrew/etc/my.cnfMain configuration file (Apple Silicon; /usr/local/etc on Intel).
data/opt/homebrew/var/mysqlData directory (Apple Silicon; /usr/local/var/mysql on Intel).

Default ports

3306

Command-line tools

  • mysqlInteractive SQL client.
  • mysqldThe database server daemon.
  • mysqladminAdministrative client (status, shutdown, password).
  • mysql_secure_installationHardening script: set the root password, remove test data.

Uninstall

Uninstall
brew services stop mysql
brew uninstall mysql

The /opt/homebrew/var/mysql data directory may remain; delete it manually to wipe everything.

Good to know

  • Homebrew's mysql starts with no root password: run mysql_secure_installation to set one.
  • The /opt/homebrew paths are for Apple Silicon; on Intel use /usr/local. Check with brew --prefix.

Installation with Homebrew

brew install mysql installs the server (mysqld) and client (mysql). Start it as a background service with brew services start mysql. The configuration is /opt/homebrew/etc/my.cnf and the data lives under /opt/homebrew/var/mysql (Apple Silicon; /usr/local on Intel).

Securing the installation

Homebrew's MySQL starts without a root password. Run mysql_secure_installation right away to set one, remove anonymous accounts, and drop the test database. Then connect with mysql -u root -p.

Common pitfalls

If port 3306 is already taken, adjust port in my.cnf and restart with brew services restart mysql. Never expose MySQL on a public interface without a strong password and a firewall.