自分用メモ
※homebrewが既に入っている前提
※またSequel Proを使用するためには現時点では、デフォルトのMySQL8.0はサポートされていないので
追記の5.7をインストールする必要がある。
インストール
$ brew install mysql
2018/11/30時点だと、MySQL8.0がインストールされる。
この時点だとでログインしようとすると・・・
$ mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
とエラーが出る。
対応策は以下のサイトさんのやり方を踏襲
blog.kuromusubi.com
※同じやり方をしても何故かコマンドが通らない場合は、「flush privileges;」を叩いてみる。
自動起動有効化
brew servicesというコマンドで自動有効化できるっぽい。
qiita.com
$ brew services start mysql
これで、LaunchAgentsにシンボリックリンクを置かなくていいっぽい。
追記
Sequel Proが現時点では、8.0に対応していないので
5.7をインストールすることにした。
インストール
8.0を先にインストールしている場合は
$ brew uninstall mysql
$ rm -rf /usr/local/var/mysql
5.7をインストール
$ brew install mysql@5.7
mysql@5.7 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 mysql@5.7 first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
デフォルトだとパスが通ってないのでパスを通す。
$ echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
$ soruce ~/.bash_profile
確認
$ mysql -v
rootにパスワードの設定
$ mysqladmin -u root password 'yourpassword'
最後に自動起動設定
$ brew services start mysql@5.7
my.cnfの場所
$ mysql --help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
上記の順番で読み込まれる。
あまり環境を汚したくないので、以下の場所でmy.cnfを設定
$ vim /usr/local/etc/my.cnf
[参考]
Install MySQL 5.7 on macOS using Homebrew · GitHub
MySQL5.7をHomebrewでmacOSにインストールする手順 | WEB ARCH LABO