macOS に Homebrew で MySQL をインストールするとバージョン8.2が入る。バージョン指定すれば8.0や5.7もインストール可能。
"Also known as: mysql@8.2"
"stable 8.2.0"
"Other versions: mysql@8.0 8.0.35"
mysql — Homebrew Formulae https://formulae.brew.sh/formula/mysql
$ brew install mysql@8.0
(中略)
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 -u root
mysql@8.0 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@8.0 first in your PATH, run:
echo 'export PATH="/usr/local/opt/mysql@8.0/bin:$PATH"' >> ~/.zshrc
(中略)
To start mysql@8.0 now and restart at login:
brew services start mysql@8.0
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mysql@8.0/bin/mysqld_safe --datadir\=/usr/local/var/mysql
==> Summary /usr/local/Cellar/mysql@8.0/8.0.35: 318 files, 301MB
==> Running `brew cleanup mysql@8.0`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
PATH を設定してから、
$ which mysql
/usr/local/opt/mysql@8.0/bin/mysql
$ mysql --version
mysql Ver 8.0.35 for macos14.0 on x86_64 (Homebrew)