If struggling with a working MySQL install on an Apple Silicon Mac...
See https://dev.to/truemark/solved-error-while-installing-mysql2-gem-in-m1-mac-1mab
Update mysql and zstd version numbers and paths as appropriate for you system:
rbenv exec gem install mysql2 -- \
--with-mysql-lib=/opt/homebrew/Cellar/mysql/8.1.0/lib \
--with-mysql-dir=/opt/homebrew/Cellar/mysql/8.1.0 \
--with-mysql-config=/opt/homebrew/Cellar/mysql/8.1.0/bin/mysql_config \
--with-mysql-include=/opt/homebrew/Cellar/mysql/8.1.0/include
bundle config --local build.mysql2 \
"--with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.5/lib"