A while ago, MySQL version 9 was released and I wanted to keep using version 8 to stay in sync with our production systems.

I found out that Homebrew allows you to pin packages to a specific version so that won't accidentally get upgraded when running brew upgrade. Here's how you can do it:

brew pin mysql

Once you've pinned a package, it won't be upgraded when running brew upgrade:

brew upgrade
Warning: Not upgrading 1 pinned package:
mysql 9.0.1_1

To unpin a package, you can use the unpin command:

brew unpin mysql

You can also list all pinned packages:

brew list --pinned