Homebrew で MySQL の古いバージョンをインストールしたときのメモ。
複数のバージョンをインストールするようなことは考慮していないので注意。
書くこと
- 環境
- やったこと
やったこと
インストールしたいバージョンがあるか確認
インストールしたい MySQL のバージョンがあるかを brew search で確認。
[shrimp]$ brew search mysql ==> Searching local taps... automysqlbackup mysql-cluster mysql-sandbox mysql@5.5 mysql mysql-connector-c mysql-search-replace mysql@5.6 mysql++ mysql-connector-c++ mysql-utilities mysqltuner ==> Searching taps on GitHub... caskroom/cask/mysql-connector-python caskroom/cask/mysql-shell caskroom/cask/sqlpro-for-mysql caskroom/cask/mysql-utilities caskroom/cask/navicat-for-mysql ==> Searching blacklisted, migrated and deleted formulae...
ここでは MySQL の 5.5 と 5.6 の Formula があるので、5.6 をインストールしてみる。
brew install する
brew search で確認したバージョンを指定して brew install する。
[shrimp]$ brew install mysql@5.6 ==> Downloading https://homebrew.bintray.com/bottles/mysql@5.6-5.6.37.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring mysql@5.6-5.6.37.sierra.bottle.tar.gz ==> Caveats A "/etc/my.cnf" from another install may interfere with a Homebrew-built server starting up correctly. MySQL is configured to only allow connections from localhost by default To connect: mysql -uroot This formula is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula. If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/mysql@5.6/bin:$PATH"' >> ~/.zshrc For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/mysql@5.6/lib CPPFLAGS: -I/usr/local/opt/mysql@5.6/include To have launchd start mysql@5.6 now and restart at login: brew services start mysql@5.6 Or, if you don't want/need a background service you can just run: /usr/local/opt/mysql@5.6/bin/mysql.server start ==> Summary 🍺 /usr/local/Cellar/mysql@5.6/5.6.37: 345 files, 154.2MB
バージョンを確認
brew install でも出力されているけど、一応確認しておく。
[shrimp]$ /usr/local/opt/mysql@5.6/bin/mysql --version /usr/local/opt/mysql@5.6/bin/mysql Ver 14.14 Distrib 5.6.37, for osx10.12 (x86_64) using EditLine wrapper
あとは必要な初期設定をしていく。