Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kangfend/97163e625cef47b40a6b0c24b05ce193 to your computer and use it in GitHub Desktop.
Save kangfend/97163e625cef47b40a6b0c24b05ce193 to your computer and use it in GitHub Desktop.
Multiple MySQL Versions with Homebrew

Install the current version of mysql.

# Install current mysql version
brew install mysql

# Start current version of mysql (including on login)
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  
# Check current mysql version
ls -la /usr/local/Cellar/mysql

Install the older version of mysql.

# Find older mysql versions
brew search mysql  
  
# Install older mysql version
brew install homebrew/versions/mysql56

# Start older version of mysql (including on login)
ln -sfv /usr/local/opt/mysql56/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist

Then to switch versions.

# Unlink current mysql version
brew unlink mysql 

# Link the older version
brew link mysql56

Or force the older link (avoid if possible).

# To force the link and overwrite all conflicting files
brew link --overwrite mysql56

Or use the switch versions command.

# To switch versions
brew switch mysql56 5.6.27

To double check which version you're on.

# Check which version of mysql is currently symlinked
ls -la /usr/local/bin/mysql

And if you only want one version running at a time.

# Stop current version of mysql
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# Stop older version of mysql
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment