MySQLクライアントの古いバージョンをHomebrewでインストールする

## 経緯

Homebrewでmysql-clientを最新化した所、
バージョンが9.0.1だと、MySQL 8.0でmysql_native_passwordのエラーが出るようになったのでダウングレードする。

```zsh
$ mysql --version
mysql  Ver 9.0.1 for macos14.4 on arm64 (Homebrew)
```

```zsh
ERROR 2059 (HY000): Authentication plugin 'mysql_native_password' cannot be loaded: dlopen(/opt/homebrew/Cellar/mysql-client/9.0.1/lib/plugin/mysql_native_password.so, 0x0002): tried: '/opt/homebrew/Cellar/mysql-client/9.0.1/lib/plugin/mysql_native_password.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/mysql-client/9.0.1/lib/plugin/mysql_native_password.so' (no such file), '/opt/homebrew/Cellar/mysql-client/9.0.1/lib/plugin/mysql_native_password.so' (no such file)
```

## 前提

Homebrewのバージョンは下記の時点で実施しています。

```
brew --version
Homebrew 4.3.12
```

## 手順

mysql-clientをアンイストールする。

```zsh
$ brew uninstall mysql-client

Uninstalling /opt/homebrew/Cellar/mysql-client/9.0.1... (120 files, 125.8MB)
==> Autoremoving 4 unneeded formulae:
libcbor
libevent
libfido2
zlib
Uninstalling /opt/homebrew/Cellar/zlib/1.3.1... (13 files, 401KB)
Uninstalling /opt/homebrew/Cellar/libfido2/1.15.0... (562 files, 1.3MB)
Uninstalling /opt/homebrew/Cellar/libevent/2.1.12_1... (57 files, 2.2MB)
Uninstalling /opt/homebrew/Cellar/libcbor/0.11.0... (33 files, 199.2KB)
```

新しいタップを作成。※mitsuaki1229部分は任意

```zsh
$ brew tap-new mitsuaki1229/taps
Warning: tap-new is a developer command, so Homebrew's
developer mode has been automatically turned on.
To turn developer mode off, run:
  brew developer off

Initialized empty Git repository in /opt/homebrew/Library/Taps/mitsuaki1229/homebrew-taps/.git/
[main (root-commit) 27e3f47] Create mitsuaki1229/taps tap
 3 files changed, 97 insertions(+)
 create mode 100644 .github/workflows/publish.yml
 create mode 100644 .github/workflows/tests.yml
 create mode 100644 README.md
==> Created mitsuaki1229/taps
/opt/homebrew/Library/Taps/mitsuaki1229/homebrew-taps

When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, label your PR as `pr-pull` and the workflow will be triggered.
```

古いバージョンを探すために、
Homebrew Coreリポジトリを強制的にタップする。

```zsh
$ brew tap homebrew/core --force
==> Tapping homebrew/core
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 2098613, done.
remote: Counting objects: 100% (351/351), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 2098613 (delta 226), reused 270 (delta 164), pack-reused 2098262
Receiving objects: 100% (2098613/2098613), 770.09 MiB | 7.28 MiB/s, done.
Resolving deltas: 100% (1513398/1513398), done.
Tapped 3 commands and 7107 formulae (7,458 files, 845.4MB).
```

特定バージョンのmysql-clientを抽出し、古いバージョンをインストールできるようにする。

```zsh
$ brew extract mysql-client mitsuaki1229/taps --version 8.3.0
==> Searching repository history
==> Writing formula for mysql-client at 8.3.0 from revision aff76a1 to:
/opt/homebrew/Library/Taps/mitsuaki1229/homebrew-taps/Formula/mysql-client@8.3.0.rb
```

古いバージョンのmysql-clientをインストールする。

```zsh
$ brew install mysql-client@8.3.0
==> Downloading https://formulae.brew.sh/api/formula.jws.json

==> Downloading https://formulae.brew.sh/api/cask.jws.json

==> Fetching dependencies for mitsuaki1229/taps/mysql-client@8.3.0: bison, cmake, pkg-config, libevent, libcbor, libfido2 and zlib
==> Fetching bison
==> Downloading https://ghcr.io/v2/homebrew/core/bison/manifests/3.8.2
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/0a84b14c20dfba4609542ea4b14a4eb93d369f7f83f373b568017fc7d76b6505--bison-3.8.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/bison/blobs/sha256:d4c06638f63876867e8fc485129ea6683487a249f0b2bc98bfaa6f1dab4ff6a4
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/02a4ba50307599f1cf641443c50be159ecfacf5c7e2e5f4feafbd51f654aac49--bison--3.8.2.arm64_sonoma.bottle.tar.gz
==> Fetching cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.30.2
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/8787197e5a78052467b35e2eb3a745b6f4de43dfeb35efe7879bb7e217d4cf55--cmake-3.30.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:e1a7afbdd456ac8cd3de0f5a1bde0489961fcca116db12e14b0802a819c72cf1
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/a8bb09f3cd0ffdce3e30b61fd5f57f538cfc78de38624d72c1040165ed20391b--cmake--3.30.2.arm64_sonoma.bottle.tar.gz
==> Fetching pkg-config
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/ac691fc7ab8ecffba32a837e7197101d271474a3a84cfddcc30c9fd6763ab3c6--pkg-config-0.29.2_3.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:7b59abc0b5381065b1eab174217307af9324e0d02edf903171b29250ae58aeaf
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/84ce7ed13999bc49b583c1b0bfd220d1bb0682ca2316d985b0f5f9e9c0a9084d--pkg-config--0.29.2_3.arm64_sonoma.bottle.tar.gz
==> Fetching libevent
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/manifests/2.1.12_1
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/68b113f9ab63db45f4e1860de522ce2ca4fa081eb3c0d5c7d6005a35c3cf8d06--libevent-2.1.12_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/blobs/sha256:38a3eb3510a7e0cd4096e4592d0095c562eb1bbad572d951f1923009a14ad702
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/8f8cf3b39994cf101de2b62af12e73a6382f97b486014945519507699919941d--libevent--2.1.12_1.arm64_sonoma.bottle.tar.gz
==> Fetching libcbor
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/manifests/0.11.0
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/547a8f3a73e95b1a6ae76032004f514d926b4dbe82bab530cb3dd011c85c23ed--libcbor-0.11.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/blobs/sha256:173091f8ffca1b73c4c17bbe5a7a6034da4e561b9e13d6e78ca536f56e364015
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/a648c68b60bb61cea080f742c86b815e851e43ee61e414e09013cccf3befe786--libcbor--0.11.0.arm64_sonoma.bottle.tar.gz
==> Fetching libfido2
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/manifests/1.15.0
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/292955ce6f66d4d7d827690a78eeac2946aab6468af64c128d6083ee8658337d--libfido2-1.15.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/blobs/sha256:af63db962f5466784b450d1052475668fdb7fd8588f6f0f52c952e4445739fda
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/b8f7890daa97b3df293bfa87921cde1d19fd614f617e20e709c064b950cf23f0--libfido2--1.15.0.arm64_sonoma.bottle.tar.gz
==> Fetching zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.3.1
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/f68d0caf232d52f2aa586abefbbfd7e958e384d84f3967008fa83de94b5f10ae--zlib-1.3.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:f867540472a59ab3fb1201625df546593e5fae2e98948c4c16c6154b0468b682
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/3e8d6a31166088ea6579bf05bcbba23cfc339221e9e7c58520655ceae782726d--zlib--1.3.1.arm64_sonoma.bottle.tar.gz
==> Fetching mitsuaki1229/taps/mysql-client@8.3.0
==> Downloading https://cdn.mysql.com/Downloads/MySQL-8.3/mysql-boost-8.3.0.tar.gz
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/e3594da2ce7dbb083f5a03611a66805b9cbf1cda67128985957fbd6a14b2eeaf--mysql-boost-8.3.0.tar.gz
==> Installing mysql-client@8.3.0 from mitsuaki1229/taps
==> Installing dependencies for mitsuaki1229/taps/mysql-client@8.3.0: bison, cmake, pkg-config, libevent, libcbor, libfido2 and zlib
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: bison
==> Downloading https://ghcr.io/v2/homebrew/core/bison/manifests/3.8.2
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/0a84b14c20dfba4609542ea4b14a4eb93d369f7f83f373b568017fc7d76b6505--bison-3.8.2.bottle_manifest.json
==> Pouring bison--3.8.2.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/bison/3.8.2: 100 files, 3.7MB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: cmake
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.30.2
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/8787197e5a78052467b35e2eb3a745b6f4de43dfeb35efe7879bb7e217d4cf55--cmake-3.30.2.bottle_manifest.json
==> Pouring cmake--3.30.2.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/cmake/3.30.2: 3,424 files, 55.3MB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: pkg-config
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/ac691fc7ab8ecffba32a837e7197101d271474a3a84cfddcc30c9fd6763ab3c6--pkg-config-0.29.2_3.bottle_manifest.json
==> Pouring pkg-config--0.29.2_3.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/pkg-config/0.29.2_3: 12 files, 679.4KB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: libevent
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/manifests/2.1.12_1
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/68b113f9ab63db45f4e1860de522ce2ca4fa081eb3c0d5c7d6005a35c3cf8d06--libevent-2.1.12_1.bottle_manifest.json
==> Pouring libevent--2.1.12_1.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libevent/2.1.12_1: 58 files, 2.2MB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: libcbor
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/manifests/0.11.0
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/547a8f3a73e95b1a6ae76032004f514d926b4dbe82bab530cb3dd011c85c23ed--libcbor-0.11.0.bottle_manifest.json
==> Pouring libcbor--0.11.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libcbor/0.11.0: 34 files, 201.8KB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: libfido2
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/manifests/1.15.0
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/292955ce6f66d4d7d827690a78eeac2946aab6468af64c128d6083ee8658337d--libfido2-1.15.0.bottle_manifest.json
==> Pouring libfido2--1.15.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libfido2/1.15.0: 562 files, 1.3MB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0 dependency: zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.3.1
Already downloaded: /Users/mitsuaki.ihara/Library/Caches/Homebrew/downloads/f68d0caf232d52f2aa586abefbbfd7e958e384d84f3967008fa83de94b5f10ae--zlib-1.3.1.bottle_manifest.json
==> Pouring zlib--1.3.1.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/zlib/1.3.1: 14 files, 403.6KB
==> Installing mitsuaki1229/taps/mysql-client@8.3.0
==> cmake -S . -B build -DFORCE_INSOURCE_BUILD=1 -DCOMPILATION_COMMENT=Homebrew -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DINSTALL_DOCDIR=share/doc/my
==> cmake --build build
==> cmake --install build
==> Caveats
mysql-client@8.3.0 is keg-only, which means it was not symlinked into /opt/homebrew,
because it conflicts with mysql (which contains client libraries).

If you need to have mysql-client@8.3.0 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql-client@8.3.0/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client@8.3.0 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql-client@8.3.0/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql-client@8.3.0/include"

For pkg-config to find mysql-client@8.3.0 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client@8.3.0/lib/pkgconfig"
==> Summary
🍺  /opt/homebrew/Cellar/mysql-client@8.3.0/8.3.0: 129 files, 151.4MB, built in 1 minute 42 seconds
==> Running `brew cleanup mysql-client@8.3.0`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> mysql-client@8.3.0
mysql-client@8.3.0 is keg-only, which means it was not symlinked into /opt/homebrew,
because it conflicts with mysql (which contains client libraries).

If you need to have mysql-client@8.3.0 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql-client@8.3.0/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client@8.3.0 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql-client@8.3.0/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql-client@8.3.0/include"

For pkg-config to find mysql-client@8.3.0 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client@8.3.0/lib/pkgconfig"
```

パスを通す。

```zsh
$ echo 'export PATH="/opt/homebrew/opt/mysql-client@8.3.0/bin:$PATH"' >> ~/.zshrc
```

```zsh
$ source ~/.zshrc
```

バージョンの確認。

```zsh
$ mysql --version
mysql  Ver 8.3.0 for macos14.6 on arm64 (Homebrew)
```

## 参考

https://shogo82148.github.io/blog/2023/03/29/2023-03-29-downgrade-homebrew/