その昔、インストールした 5.6
と比べて挙動が違ったのでメモ。
brew install
まずは brew install するところから
$ brew install mysql@5.7
==> Downloading https://homebrew.bintray.com/bottles/mysql@5.7-5.7.26.mojave.bottle.tar.gz
Already downloaded: /Users/<your name>/Library/Caches/Homebrew/downloads/665d7cef7caaddc43ad93397ebb4a9cf1737a905403381440be05956e06e35a2--mysql@5.7-5.7.26.mojave.bottle.tar.gz
==> Pouring mysql@5.7-5.7.26.mojave.bottle.tar.gz
==> /usr/local/Cellar/mysql@5.7/5.7.26/bin/mysqld --initialize-insecure --user=t_horikoshi --basedir=/usr/local/Cellar/mysql@5.7/5.7.26 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
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
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"
For pkg-config to find mysql@5.7 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺 /usr/local/Cellar/mysql@5.7/5.7.26: 320 files, 231.8MB
接続を試みるも失敗...。
$ mysql -uroot
fish: Unknown command mysql
brew services start
こちらを参考に brew services start
とやらをやってみる。
$ brew services start mysql@5.7
接続できるようになる
💪
$ mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.16 Homebrew
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
brew services start mysql@5.7
インストール時のログに出てたね。