Bundle Install – missing mysql.h

If you’re seeing the following error:

checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
mysql.h is missing.  please check your installation of mysql and try again.

The way I was able to resolve it was to follow Boonedocks.net, since I’m also using MAMP for its MySQL Database instance.

The only difference is that I already had MAMP 1.9.4 installed and so I had to download the MAMP_components_1.9.dmg which contains the mysql-5.1.44 source code. MAMP 1.9.4 comes with mysql-5.1.44 but I needed the source code so I can compile libraries so the mysql Gem can link against it.

Here are the steps, assuming you already have MAMP or a separate standalone MySQL instance installed.

However, you should be able to follow similar instructions even if you don’t have MAMP installed. If you don’t have MAMP installed, correct the paths referenced below, as these ones below reference the MAMP directory.

  1. Figure out which version of mysql you have installed by running mysql from the prompt or checking your phpinfo page
  2. Download and Install the MAMP_components_1.x.dmg or the MySQL source code. The version should match your current mysql version though in order to avoid issues. Inside the MAMP Components, you should see a mysql tarball. You need to untar/unzip that.
  3. cd into the mysql-5.x source directory
  4. Assuming you have MAMP installed, type the following: ./configure –with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock –without-server –prefix=/Applications/MAMP/Library
  5. Execute: make -j2
  6. Execute: cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql
  7. Execute: mkdir /Applications/MAMP/Library/include
  8. Execute: cp -R include /Applications/MAMP/Library/include/mysql
  9. Execute: sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)
Facebook Twitter Email

One Comment to “Bundle Install – missing mysql.h”

  1. Anthony 22 December 2011 at 8:01 pm #

    I’m stuck on step 4:

    $ ./configure –with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock –without-server –prefix=/Applications/MAMP/Library

    configure: error: invalid variable name: –with-unix-socket-path

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply