Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mitchkramez/34a3db8f660fecb125f1015e8e1dc387 to your computer and use it in GitHub Desktop.
Save mitchkramez/34a3db8f660fecb125f1015e8e1dc387 to your computer and use it in GitHub Desktop.
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions with Homebrew

For homebrew version 1.5.12 - WIP... not quite working yet.

brew -v # => Homebrew 1.5.12

Install the current version of mysql.

# Install current mysql version
brew install mysql

# Start agent for current version of mysql (including on login)
brew services start mysql

Install the older version of mysql.

# Find older mysql versions
brew search mysql  
  
# Install older mysql version
brew install [email protected] 5.6.39

# Start agent for older version of mysql (including on login)
brew services start [email protected]

Then to switch to the older version.

# Unlink current mysql version
brew unlink mysql 

# Check older mysql version
ls /usr/local/Cellar/[email protected] # => 5.6.39

# Link the older version
brew switch mysql 5.7.21

And to switch back to the current version.

# Unlink older mysql version
brew unlink [email protected] 

# Check current mysql version
ls /usr/local/Cellar/mysql # =>  5.7.21

# Link the current version
brew switch mysql 5.7.10

To verify which mysql version you're on at any time.

# Check which version of mysql is currently symlinked
ls -l /usr/local/bin/mysql # => /usr/local/bin/mysql@ -> ../Cellar/mysql56/5.6.27/bin/mysql

# Or using the mysql command
mysql --version

And to unload a mysql agent for a given version.

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

# Stop agent for older version of mysql
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
@ibushong
Copy link

A few of these sections don't look right. For example in "Then to switch to the older version", you "find" version 5.6.39 but then you switch to 5.7.21. Shouldn't that last statement be brew switch [email protected] 5.6.39?

@hex0id
Copy link

hex0id commented Feb 7, 2019

my way around this was as simple as:
brew services stop mysql
brew install [email protected] (since the upgraded mysql 8 was already installed as "mysql")
brew unlink mysql
brew link -force [email protected]
brew services start [email protected]

the problem initially was "brew switch mysql 5.7.23" did not work for me with error that "cellar does not contain that version"...

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