4

I'm trying to use the mysql2 gem with rails 3.1.0.rc6, but I'm having some problem with my mysql client.

I'm getting this message when trying to start my server.

Incorrect MySQL client library version! This gem was compiled for 5.1.53 but the client library is 5.5.14. (RuntimeError)

How do I compile/install mysql2 so that is can use mysql 5.5.14?

I've tried using gem pristine mysql2 without success.

Linus Oleander
  • 17,746
  • 15
  • 69
  • 102

3 Answers3

12

The problem here was that the MySQL2 gem was compiled for the MySQL version installed by Apple (Development package) not by me using Homebrew.

Using this command when installing the gem solved the problem.

gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.14/bin/mysql_config

Don't forget to install mysql using:

sudo brew install mysql

The problem now is that we somehow need to pass the option to bundler, to do that you can use bundler config.

bundle config build.mysql2 --with-mysql-config=/usr/local/Cellar/mysql/5.5.14/bin/mysql_config

Running bundle install in your ruby app should now work.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Linus Oleander
  • 17,746
  • 15
  • 69
  • 102
  • 1
    bundle config command didn't work for me (brew mysql didn't install so install alternative version) on lion. gem pristine mysql2 actually solved it somehow! :) – Daniel Morris Jul 02 '12 at 00:25
  • This answer worked for me, however I had to perform one extra step not mentioned in the answer. When I tried to do `brew install mysql` i got the following error `Error: mysql-5.5.19 already installed To install this version, first 'brew unlink mysql'`, so I ran this: `brew unlink mysql` before `brew install mysql` and then the rest of the steps in the answer worked and solved my problem. – Livi17 Oct 07 '14 at 23:22
0

What worked for me in a similar situation:

brew reinstall mysql
gem pristine mysql2
bluemihai
  • 405
  • 4
  • 15
0

Looks like unmatched version with mysql client library and mysql2 compiled gem give LoadError.

So, they explictly raise RuntimeError for that

So, only the way I aware is, download the source from github and compile it in your machine.

YOU
  • 120,166
  • 34
  • 186
  • 219