Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Samnan/b506a3fbdc314624d96ac0e5571dd9d2 to your computer and use it in GitHub Desktop.

Select an option

Save Samnan/b506a3fbdc314624d96ac0e5571dd9d2 to your computer and use it in GitHub Desktop.

Revisions

  1. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # Multiple MySQL Versions for Development

    Includes instructions for:
    - docker-compose
    - brew (homebrew)
    Options included below:
    - Using Docker `docker-compose`
    - Using Homebrew `brew`

    ## Option 1: Using Docker (recommended)
    ## Using Docker (recommended)

    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.

    @@ -35,7 +35,7 @@ To stop your mysql service.

    docker-compose down # or ctrl-c if service is running in foreground

    ## Option 2: Using Homebrew
    ## Using Homebrew

    **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.

  2. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Includes instructions for:
    - docker-compose
    - brew (homebrew)

    ## Multiple MySQL Versions using Docker (recommended)
    ## Option 1: Using Docker (recommended)

    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.

    @@ -35,7 +35,7 @@ To stop your mysql service.

    docker-compose down # or ctrl-c if service is running in foreground

    ## Multiple MySQL Versions using Homebrew
    ## Option 2: Using Homebrew

    **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.

  3. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Includes instructions for:
    - docker-compose
    - brew (homebrew)

    ## Using Docker (recommended)
    ## Multiple MySQL Versions using Docker (recommended)

    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.

    @@ -35,7 +35,7 @@ To stop your mysql service.

    docker-compose down # or ctrl-c if service is running in foreground

    ## Using Homebrew
    ## Multiple MySQL Versions using Homebrew

    **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.

  4. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Includes instructions for:

    ## Using Docker (recommended)

    This gist was created before the rise of Docker, and it may be best to avoid installing mysql via `brew` any more. Instead consider adding a barebones `docker-compose.yml` for each project and run `docker-compose up` to start each project's mysql service.
    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**
    ```
  5. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,14 @@ volumes:

    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

    ## Using Homebrew

    **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.
  6. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions multiple_mysql_versions_for_development.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    # Multiple MySQL Versions for Development

    Includes instructions for:
    - docker-compose
    - brew (homebrew)

    ## Using Docker (recommended)

    This gist was created before the rise of Docker, and it may be best to avoid installing mysql via `brew` any more. Instead consider adding a barebones `docker-compose.yml` for each project and run `docker-compose up` to start each project's mysql service.
  7. @benlinton benlinton renamed this gist Jun 11, 2019. 1 changed file with 0 additions and 0 deletions.
  8. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Using Docker (recommended)

    This gist was created before the rise of Docker. As an alternative, it may be best to avoid installing mysql via `brew`. Instead add a barebones `docker-compose.yml` for each project and run `docker-compose up` to start each project's mysql service.
    This gist was created before the rise of Docker, and it may be best to avoid installing mysql via `brew` any more. 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**
    ```
  9. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 29 additions and 26 deletions.
    55 changes: 29 additions & 26 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,33 @@
    # Multiple MySQL Versions with Homebrew
    # Multiple MySQL Versions for Development

    For homebrew version 0.9.5.
    ## Using Docker (recommended)

    This gist was created before the rise of Docker. As an alternative, it may be best to avoid installing mysql via `brew`. Instead add 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.)

    ## Using Homebrew

    **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

    @@ -50,27 +77,3 @@ To verify which mysql version you're on at any time.

    # Or using the mysql command
    mysql --version


    # Consider Docker as an Alternative

    This gist was created before the rise of Docker. As an alternative, it may be best to avoid installing mysql via `brew`. And instead add a barebones `docker-compose.yml` to each project and run `docker-compose up` to start your 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.)
  10. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ To verify which mysql version you're on at any time.

    This gist was created before the rise of Docker. As an alternative, it may be best to avoid installing mysql via `brew`. And instead add a barebones `docker-compose.yml` to each project and run `docker-compose up` to start your mysql service.

    *docker-compose.yml*
    **docker-compose.yml**
    ```
    version: "3.7"
    services:
  11. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 30 additions and 20 deletions.
    50 changes: 30 additions & 20 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Multiple MySQL Versions with Homebrew
    # Multiple MySQL Versions with Homebrew

    For homebrew version 0.9.5.

    @@ -9,21 +9,17 @@ Install the current version of mysql.
    # Install current mysql version
    brew install mysql

    # Start agent for current version of mysql (including on login)
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    # Start agent for current version of mysql
    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]

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

    Then to switch to the older version.

    @@ -54,13 +50,27 @@ To verify which mysql version you're on at any time.

    # 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


    # Consider Docker as an Alternative

    This gist was created before the rise of Docker. As an alternative, it may be best to avoid installing mysql via `brew`. And instead add a barebones `docker-compose.yml` to each project and run `docker-compose up` to start your 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.)
  12. @benlinton benlinton revised this gist Jun 11, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ Install the older version of mysql.
    brew search mysql

    # Install older mysql version
    brew install homebrew/versions/mysql56
    brew install [email protected]

    # Start agent for older version of mysql (including on login)
    ln -sfv /usr/local/opt/mysql56/*.plist ~/Library/LaunchAgents
    @@ -34,7 +34,7 @@ Then to switch to the older version.
    ls /usr/local/Cellar/mysql56 # => 5.6.27

    # Link the older version
    brew switch mysql56 5.6.27
    brew switch [email protected] 5.6.27

    And to switch back to the current version.

  13. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,10 @@ And to switch back to the current version.
    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
    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.

  14. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ 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

    And if you only want only one version's agent running at a time (database agents/daemons can use a lot of resources).
    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
  15. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    ## Multiple MySQL Versions with Homebrew

    For homebrew version 0.9.5.

    brew -v # => Homebrew 0.9.5

    Install the current version of mysql.

    # Install current mysql version
  16. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Multiple MySQL Versions with Homebrew
    ## Multiple MySQL Versions with Homebrew

    Install the current version of mysql.

  17. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Multiple MySQL Versions with Homebrew

    Install the current version of mysql.

    # Install current mysql version
  18. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Then to switch to the older version.
    brew unlink mysql

    # Check older mysql version
    ls -la /usr/local/Cellar/mysql56 # => 5.6.27
    ls /usr/local/Cellar/mysql56 # => 5.6.27

    # Link the older version
    brew switch mysql56 5.6.27
    @@ -36,15 +36,15 @@ And to switch back to the current version.
    brew unlink mysql56

    # Check current mysql version
    ls -la /usr/local/Cellar/mysql # => 5.7.10
    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 -la /usr/local/bin/mysql
    ls -l /usr/local/bin/mysql

    And if you only want only one version's agent running at a time (database agents/daemons can use a lot of resources).

  19. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ Install the current version of mysql.
    # Install current mysql version
    brew install mysql

    # Start current version of mysql (including on login)
    # Start agent for current version of mysql (including on login)
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    @@ -15,7 +15,7 @@ Install the older version of mysql.
    # Install older mysql version
    brew install homebrew/versions/mysql56

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

    @@ -24,7 +24,7 @@ Then to switch to the older version.
    # Unlink current mysql version
    brew unlink mysql

    # Check current mysql version
    # Check older mysql version
    ls -la /usr/local/Cellar/mysql56 # => 5.6.27

    # Link the older version
    @@ -41,17 +41,17 @@ And to switch back to the current version.
    # Link the current version
    brew switch mysql 5.7.10

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

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

    And if you only want only one version's daemon running at a time.
    And if you only want only one version's agent running at a time (database agents/daemons can use a lot of resources).

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

    # Stop older version of mysql
    # Stop agent for older version of mysql
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
    rm ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
  20. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ To verify which version of mysql you're on.
    # Check which version of mysql is currently symlinked
    ls -la /usr/local/bin/mysql

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

    # Stop current version of mysql
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  21. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ And to switch back to the current version.
    # Link the current version
    brew switch mysql 5.7.10

    To check which version you're on.
    To verify which version of mysql you're on.

    # Check which version of mysql is currently symlinked
    ls -la /usr/local/bin/mysql
  22. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,9 @@ Then to switch to the older version.
    # Unlink current mysql version
    brew unlink mysql

    # Check current mysql version
    ls -la /usr/local/Cellar/mysql56 # => 5.6.27

    # Link the older version
    brew switch mysql56 5.6.27

  23. @benlinton benlinton revised this gist Dec 20, 2015. 1 changed file with 11 additions and 13 deletions.
    24 changes: 11 additions & 13 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,6 @@ Install the current version of mysql.
    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
    @@ -22,30 +19,31 @@ Install the older version of mysql.
    ln -sfv /usr/local/opt/mysql56/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist

    Then to switch versions.
    Then to switch to the older version.

    # Unlink current mysql version
    brew unlink mysql

    # Link the older version
    brew link mysql56
    brew switch mysql56 5.6.27

    Or force the older link (avoid if possible).
    And to switch back to the current version.

    # To force the link and overwrite all conflicting files
    brew link --overwrite mysql56
    # Unlink older mysql version
    brew unlink mysql56

    Or use the switch versions command.
    # Check current mysql version
    ls -la /usr/local/Cellar/mysql # => 5.7.10

    # To switch versions
    brew switch mysql56 5.6.27
    # Link the current version
    brew switch mysql 5.7.10

    To double check which version you're on.
    To 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.
    And if you only want only one version running at a time.

    # Stop current version of mysql
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  24. @benlinton benlinton created this gist Dec 20, 2015.
    56 changes: 56 additions & 0 deletions homebrew_multiple_mysql_versions.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    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