Skip to content

Instantly share code, notes, and snippets.

@robhrt7
Forked from nrollr/MySQL_macOS_Sierra.md
Last active September 10, 2025 15:05
Show Gist options
  • Save robhrt7/392614486ce4421063b9dece4dfe6c21 to your computer and use it in GitHub Desktop.
Save robhrt7/392614486ce4421063b9dece4dfe6c21 to your computer and use it in GitHub Desktop.
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 8 as default, but as we're aiming to get 5.7, we'll need to append @5.7 to the default package key:

To install MySQL enter : $ brew install [email protected]

Additional configuration

Homebrew

  • Install brew services first : $ brew tap homebrew/services

  • Load and start the MySQL service : $ brew services start [email protected].
    Expected output : Successfully started mysql (label: homebrew.mxcl.mysql)

  • Check of the MySQL service has been loaded : $ brew services list 1

  • Force link 5.7 version - $ brew link [email protected] --force

  • Verify the installed MySQL instance : $ mysql -V.
    Expected output : Ver 14.14 Distrib 5.7.22, for osx10.13 (x86_64)

MySQL

Open Terminal and execute the following command to set the root password:
mysqladmin -u root password 'yourpassword'

Important : Use the single ‘quotes’ to surround the password and make sure to select a strong password!

Database Management

To manage your databases, I recommend using Sequel Pro, a MySQL management tool designed for macOS.
Current version available: 1.1.2

Comments

1 The brew services start [email protected] - instruction is equal to :

$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
@ferrucc-io
Copy link

ferrucc-io commented Sep 9, 2025

This doesn't work for me anymore because

The brew tap homebrew/core --force doesn't work because MySQL 5.7 was completely removed from the repository, not just disabled.

See https://github.com/Homebrew/homebrew-core/blob/main/Formula/m/mysql%405.7.rb

What worked for me was placing the formula that was previously there in: /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m

Did this doing:

sudo curl -fL "https://raw.githubusercontent.com/Homebrew/homebrew-core/6c907880b95a3702348c1fcce1c661fcc03336e5/Formula/m/mysql%405.7.rb" \
  -o "/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m/[email protected]"

Followed by this to remove the disable from the formula:

sudo sed -i '' '/disable! date: "2024-08-01", because: :unsupported/d' /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m/[email protected]

And you need to do the same for [email protected]:

sudo curl -fL "https://raw.githubusercontent.com/Homebrew/homebrew-core/6c907880b95a3702348c1fcce1c661fcc03336e5/Formula/o/openssl%401.1.rb" \
  -o "/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/o/[email protected]"
 
 sudo sed -i '' '/disable! date: "2024-10-24", because: :unsupported/d' /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/o/[email protected]

Note, if the previous steps fails because of missing directories not existing you might also need to create them for both (sudo mkdir -p "/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/o" and sudo mkdir -p "/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m"`)

Then you can install both mysql and openssl like:

brew tap-new local/old-openssl
cp /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/o/[email protected] \
   $(brew --repository local/old-openssl)/Formula/[email protected]
brew install local/old-openssl/[email protected]

brew tap-new local/old-mysql
cp /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m/[email protected] \
   $(brew --repository local/old-mysql)/Formula/[email protected]
brew install local/old-mysql/[email protected]

brew install local/old-mysql/[email protected]

@nivank7
Copy link

nivank7 commented Sep 10, 2025

@ferrucc-io trying the same workaround but it does not work on sequoia, which OS are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment