How to install MySQL gem on Mac OS X

synapse picture synapse · Feb 11, 2011 · Viewed 26.1k times · Source

What do I need to install mysql gem on Mac OS X ? I'm getting error "failed to build native extensions".

Answer

Krule picture Krule · Feb 11, 2011

Install MySQL first, either by using binary or Homebrew.

Then:

gem install mysql2

Or:

gem install ruby-mysql

Just pick one and you are good to go.


Edit

In case you upgraded to MySQL version 5.6.12 on OS X, mysql2 will fail to compile. Solution is to downgrade MySQL as described here: https://stackoverflow.com/a/17252887/45254


Edit2

In case you don't want to have mysql installed (maybe you use docker to manage your services) but do want to use mysql2 gem, you can instead install mysql-connector-c (using homebrew).