Installing MySQL on MacOS

By Ercan - 26/06/2025

If you're developing locally on a Mac and prefer running MySQL natively instead of using Docker, this guide is for you. I personally run several personal projects on my MacBook and want my data to persist without relying on containers.

Here’s how to install and secure MySQL using Homebrew, with architecture-specific instructions for Apple Silicon and Intel-based Macs.


Step 1: Install MySQL

brew install mysql

By default, MySQL creates a root user without a password. For security reasons, I prefer setting a password manually.

Step 2: Start MySQL Temporarily

brew services run mysql

This starts MySQL just for the current session. I avoid running it as a background service to preserve battery life.

Step 3: Run Secure Installation Tool

Depending on your architecture, run the appropriate command:

On Apple Silicon (ARM64):

/opt/homebrew/opt/mysql/bin/mysql_secure_installation

On Intel:

/usr/local/opt/mysql/bin/mysql_secure_installation

During the process, you’ll be asked:

  • Whether to install the VALIDATE PASSWORD COMPONENT — I skip this for local use.
  • Set a root password.
  • Remove anonymous users → Yes
  • Disallow root login remotely → Yes
  • Remove test database → Yes
  • Reload privilege tables → Yes

This completes the secure setup.

Step 4: Stop MySQL When Not Needed

brew services stop mysql

I only run MySQL when I need it, using brew services run mysql, and stop it afterward to save resources.

💡 You can also find the full command list in this GitHub Gist.

Tags: mysql