Skip to content

Instantly share code, notes, and snippets.

@fernandoaleman
Created November 2, 2023 16:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fernandoaleman/cc24771002005a37b86bc4e021306031 to your computer and use it in GitHub Desktop.
Save fernandoaleman/cc24771002005a37b86bc4e021306031 to your computer and use it in GitHub Desktop.
How to install mysql2 gem on apple silicon M1, M2 or M3 macOS Sonoma

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using

brew install mysql-client openssl zstd

Install mysql2 gem.

Replace 0.5.2 with whichever version you are using

 gem install mysql2 -v '0.5.2' -- --with-mysql-lib=$(brew --prefix mysql-client)/lib --with-mysql-dir=$(brew --prefix mysql-client) --with-mysql-config=$(brew --prefix mysql-client)/bin/mysql_config --with-mysql-include=$(brew --prefix mysql-client)/include --with-ldflags="-L$(brew --prefix zstd)/lib -L$(brew --prefix openssl)/lib -L$(brew --prefix zlib)/lib" --with-cppflags="-I$(brew --prefix openssl)/include -I$(brew --prefix zlib)/include"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment