MySQL Install: ERROR: Failed to build gem native extension
First of all you need to differentiate between the MySQL as Server, MySQL as Client and the Ruby bindings to MySQL.
I'm not familiar with Mac, but for *nix OS you need to install MySQL through your package manager. To get the Ruby bindings installed with
gem install mysql
you need the development headers of ruby (in Ubuntu it is the package ruby-dev) and the development headers of the MySQL-Client (currently libmysqlclient16-dev
in Ubuntu). I don't know if they are named different on Mac, but after you got those installed the Ruby bindings should install without any error.
Installing the mysql gem on OSX
in a terminal.. First do a ‘locate mysql_config’ and then replace the path in the following command with where that file is.
$ sudo gem install mysql -- —–with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.7
1 gem installed
On Debian (or Ubuntu) systems, just install libmysqlclient-dev package using:
sudo apt-get install libmysqlclient-dev
and then:
gem install mysql
It will be installed without any error.