Options included below:
- Using Docker docker-compose
- Using Homebrew brew
This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer.  Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.
docker-compose.yml
version: "3.7"
services:
  db:
    image: mysql:5.6
    restart: always
    ports:
      - "3306:3306"
    volumes:
      - "db_data:/var/lib/mysql"
volumes:
  db_data: null
Please visit https://hub.docker.com/_/mysql for environment variables that you can optionally set (e.g. username, password, etc.)
To start the your mysql service.
docker-compose up
To stop your mysql service.
docker-compose down  # or ctrl-c if service is running in foreground
Disclaimer: Your milage may vary, I've updated this gist based on comments below but haven't tested it myself since switching to Docker. Please see comments below and/or gist history for additional details.
I was using homebrew version 0.9.5 when writing this gist.
brew -v # => Homebrew 0.9.5
Install the current version of mysql.
# Install current mysql version
brew install mysql
# Start agent for current version of mysql
brew services start mysql
Install the older version of mysql.
# Install older mysql version
brew install [email protected]
# Start agent for older version of mysql
brew services stop mysql
brew services start mysql56
Then to switch to the older version.
# Unlink current mysql version
brew unlink mysql 
# Check older mysql version
ls /usr/local/Cellar/mysql56 # => 5.6.27
# Link the older version
brew switch [email protected] 5.6.27
And to switch back to the current version.
# Unlink older mysql version
brew unlink mysql56 
# Check current mysql version
ls /usr/local/Cellar/mysql # => 5.7.10
# 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
@jpmelguizo I also had your problem. My issue was that the [email protected] was trying to boot the mysql 5.7 database (installed in the default
/usr/local/varfolder). If you want to run both in parallel on their own distinct databases, there are a few more steps to do.Create a new (separate) data directory and database for the 5.6 version
Run
/usr/local/Cellar/[email protected]/5.6.36/bin/mysql_install_db --user=root --datadir=/usr/local/var/mysql56Change the configuration to start the 5.6 version pointing to this database
Edit
/usr/local/Cellar/[email protected]/5.6.36/[email protected]to change both/usr/local/var/mysqlinstances to/usr/local/var/mysql56(I didn't put the@in the folder name just in case it would cause issues).Edit
/usr/local/Cellar/[email protected]/5.6.36/my.cnf, uncommentportand change it to some other value than3306.NOTE A little caveat about connecting to the MySQL instances after such a setup. Using any kind of driver will work out of the box if you set the correct port. However, at the command line,
mysqlignores the--portvalue by default, so you need something like thismysql -uroot --port=3356 --protocol=TCPSee this article for more details: https://dev.mysql.com/doc/refman/5.7/en/connecting.html