Ruby mysql2 gem编译为错误的mysql客户端库版本 [英] Ruby mysql2 gem compiled for wrong mysql client library version

查看:153
本文介绍了Ruby mysql2 gem编译为错误的mysql客户端库版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用apt-get将MySQL更新到5.5之后, mysql2 gem停止工作。

这是错误:

 不正确的MySQL客户端库版本! 
此宝石编译为5.5.17,但客户端库为5.1.58。 (RuntimeError)

我试着用mysql_config重新安装,但它似乎没有区别。 / p>

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

相应地,我试着告诉bundle使用mysql-config编译mysql2,但仍然存在错误。

  bundle config build.mysql2 --with-mysql-config = / usr / bin / mysql_config 
bundle install
p>




以下是在尝试使用最新版本的mysql2 gem时的完整错误堆栈:

  [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':不正确的MySQL客户端库版本!这个宝石编译为5.5.17,但客户端库是5.1.58。 (RuntimeError)$ / b / b来自/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb:9:位于/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/中的< top(required)>'
中lib / bundler / runtime.rb:68:在'require'中
来自/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0 .21 / lib / bundler / runtime.rb:68:在block中(2级)需要'
来自/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/ 1.9.1 / gems / bundler-1.0.21 / lib / bundler / runtime.rb:66:在'each'中$ / b / b /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:在`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:在'require'
/users/marco/.rbenv/版本/ 1.9.3-p0 / lib / ruby​​ / gems / 1.9.1 / gems / bundler-1.0.21 / lib / bundler.rb:122:在'require'
从/www/config/application.rb: 7:在/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.1的`< top(required)>'
中。 1 / lib / rails / commands.rb:38:在'require'中
来自/users/marco/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties -3.1.1 / lib / rails / commands.rb:38:在脚本/导轨的< top(required)>'
中:'require'
脚本/ 6:在< main>'






编辑:我从缓存中删除所有mysql2 gemspecs,通过apt-get卸载所有与mysql相关的包,并重新安装所有内容,然后再次尝试使用mysql-config标志安装gem ..但它都证明了徒劳的。错误依然存在。



编辑2 :正如John Bachir所建议的,我确认mysql_config包含MySQL 5.5版本。

解决方案

使用Ubuntu Server 11.04和Percona Server时遇到同样的错误,我做了什么:



/usr/lib/libmysqlclient.so.16.0.0 替换为 /usr/lib/libmysqlclient.so.18.0.0


After updating MySQL to 5.5 using apt-get, the mysql2 gem stopped working.

Here's the error:

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

I tried reinstalling with mysql_config but it doesn't seem to make a difference..

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

Correspondingly, I tried telling bundle to compile mysql2 with mysql-config but still, the error remains..

bundle config build.mysql2 --with-mysql-config=/usr/bin/mysql_config
bundle install

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.


Here's the full error stack when trying the most current version of the mysql2 gem:

[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 `<top (required)>'
  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 `<top (required)>'
  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 `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'


Edit: 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.

Edit 2: As suggested by John Bachir, I confirmed that mysql_config contains MySQL version 5.5.

解决方案

I have encounter the same error when using Ubuntu Server 11.04 and Percona Server, what have I done was:

replace /usr/lib/libmysqlclient.so.16.0.0 with /usr/lib/libmysqlclient.so.18.0.0

这篇关于Ruby mysql2 gem编译为错误的mysql客户端库版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆