brewコマンドでアップグレードしてしまった時に、動かなくなりました。
エラー内容はこんな感じです。
dlopen(/Users/xxxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/opt/mysql/lib/libmysqlclient.20.dylib (LoadError) Referenced from: /Users/xxxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle Reason: image not found - /Users/xxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
libmysqlclient.20.dylib\
mysql8になると、↑の20のところが21になるようですね。
直した時のコマンドはこんな感じでした。
brew uninstall mysql brew install mysql@5.7 bundle exec gem uninstall mysql2 rbenv exec bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include" or bundle install
mysqlのバージョンをチェック
mysql --version