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

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

问题描述

当尝试通过Rails应用程序连接到mysql服务器时,出现以下错误

When try to connect to the mysql server through my rails application, I get the following error

D:/Program_Files/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': 
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.27. (RuntimeError)

我该如何纠正?

推荐答案

我和您有相同的问题,或者至少症状是相同的.

I had the same problem as you, or at least the symptom was the same.

背景:我正在使用Windows计算机本地安装的Rails 3,mysql2 gem和MySQL社区服务器版本5.5.21(32位).我从MySQL安装中获取了客户端库(libmysql.dll),并将其复制到了ruby安装的bin文件夹中.

Background: I was using Rails 3, the mysql2 gem, and MySQL community server version 5.5.21 (32-bit) installed locally on my Windows machine. I grabbed the client library (libmysql.dll) from the MySQL installation and copied it to my ruby installation's bin folder.

当我运行bundle exec rake db:create时,收到与您相同的错误消息,我想:嘿,当我从最新的MySQL版本中获得客户端库时,该客户端库怎么过时了?"

When I ran bundle exec rake db:create, I got the same error message as you and I thought "Hey, how can the client library be outdated when I got it from the latest MySQL release?"

gem install mysql2时会显示一条有用的消息.不幸的是,如果您与Bundler一起安装gem,则Bundler会收到消息.在这里:

There's a helpful message that is shown when you gem install mysql2. Unfortunately, if you install the gem with Bundler, Bundler eats the message. Here it is:

=========================================================================
You've installed the binary version of mysql2. It was built using MySQL 
Connector/C version 6.0.2. It's recommended to use the exact same version
to avoid potential issues.

At the time of building this gem, the necessary DLL files where available
in the following download:

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin

按照这些说明为我解决了这个问题.

Following these instructions solved the problem for me.

参考链接

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

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