I was trying to install Ruby’s mysql2 gem on my Windows 7 computer, running MySQL 64-bits. It turns out that the mysql2 gem is not compatible with MySQL 64-bits libmysql.dll file. The solution is building the gem against the 32-bits version of the MySQL library, which thankfully turns out to be compatible. When installing the […]

This article was posted by Independent Software, a website and database application development company based in Maputo, Mozambique. Our website offers regular write-ups on technical and design issues, ranging from details at code level to 3D Studio Max rendering. Read more about Independent Software's philosophy, or get in touch with Independent Software.

I was trying to install Ruby’s mysql2 gem on my Windows 7 computer, running MySQL 64-bits. It turns out that the mysql2 gem is not compatible with MySQL 64-bits libmysql.dll file. The solution is building the gem against the 32-bits version of the MySQL library, which thankfully turns out to be compatible.

When installing the Ruby mysql 2 gem with MySQL 64-bits installed on your system, you get something like:

In other words, yet get a bunch of undefined references to functions that should exist in libmysql.dll. Except they don’t, because you’re running MySQL 64-bits and its functions have a different signature.

The solution is this: get the installation files for MySQL 32-bits (same version as yours), and copy the libmysql.dll file to your Ruby installation’s library directory  (C:Ruby192lib, for instance). Now linking will succeed.

Did this article help you out? Please help us find more time to write useful guides & articles like this by donating a buck or two. It'll keep us coffee-fueled. Thanks!

Comments

1 One Response to “Installing Ruby’s mysql2 gem for MySQL 64-bits”
  1. Chris says:

    After reading hundreds of posts and trying out solutions for hours I came across your article. No one else has addressed the 64 bit issue. Thank you so much, you saved me!

Leave a Reply

Your email address will not be published. Required fields are marked *