title: Ruby mysql2 gem compiled for wrong mysql client library version
body: <p>After updating MySQL to 5.5 using apt-get, the <code>mysql2</code> gem stopped working.</p>
  
  <p>Here's the error:</p>
  
  <pre><code>Incorrect MySQL client library version!
  This gem was compiled for 5.5.17 but the client library is 5.1.58. (RuntimeError)
  </code></pre>
  
  <p>I tried reinstalling with mysql_config but it doesn't seem to make a difference..</p>
  
  <pre><code>gem install mysql2 -- --with-mysql-config=/usr/bin/mysql_config
  </code></pre>
  
  <p>Correspondingly, I tried telling bundle to compile mysql2 with mysql-config but still, the error remains..</p>
  
  <pre><code>bundle config build.mysql2 --with-mysql-config=/usr/bin/mysql_config
  bundle install
  </code></pre>
  
  <p>When I tried an older version of the gem (v0.2.6) the rails console opens but crashes once I run any type of query.</p>
  
  <hr>
  
  <p>Here's the full error stack when trying the most current version of the mysql2 gem:</p>
  
  <pre><code>[marco@linode:/www] 07:29:00 AM: rails c
  /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb:9:in `require': Incorrect MySQL client library version! This gem was compiled for 5.5.17 but the client library is 5.1.58. (RuntimeError)
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb:9:in `&lt;top (required)&gt;'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /www/config/application.rb:7:in `&lt;top (required)&gt;'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:38:in `require'
    from /users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.1.1/lib/rails/commands.rb:38:in `&lt;top (required)&gt;'
    from script/rails:6:in `require'
    from script/rails:6:in `&lt;main&gt;'
  </code></pre>
  
  <hr>
  
  <p><strong>Edit</strong>: I removed all mysql2 gemspecs from cache, uninstalled all mysql-related packages via apt-get and reinstalled everything afresh, then tried again to install the gem with the mysql-config flag .. but it all proved futile. The error remains.</p>
  
  <p><strong>Edit 2</strong>: As suggested by John Bachir, I confirmed that mysql_config contains MySQL version 5.5.</p>