You are here

Install MySQL Gem in Mac OS - using MacPorts

While trying to install the MySQL gem in a Mac OS Lion, you might get an error message:

$ sudo gem install mysql -v '2.8.1'
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
....
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

I then decided to install a MySQL developer package, but before that I installed MacPorts. Two very simple steps:

  1. Download and install MacPorts, which is a package handler and installer for Mac OS - like apt-get or yum.
  2. Install the mysql5 developer package.
  3. $ sudo port install mysql5-devel

Now install the MySQL Gem.

sudo gem install mysql -v '2.8.1'