为错误的mysql客户端库版本编译的Ruby mysql2 gem

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

问题描述

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

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

这是错误:

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

我尝试使用 mysql_config 重新安装,但似乎没有什么不同..

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

相应地,我尝试告诉 bundle 用 mysql-config 编译 mysql2,但错误仍然存​​在..

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

当我尝试使用旧版本的 gem (v0.2.6) 时,rails 控制台会打开,但一旦我运行任何类型的查询就会崩溃.

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.

这是尝试最新版本的 mysql2 gem 时的完整错误堆栈:

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>'

<小时>

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


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.

编辑 2:按照 John Bachir 的建议,我确认 mysql_config 包含 MySQL 5.5 版.

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

推荐答案

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

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

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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)