小编典典

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

mysql

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

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)

我该如何纠正?


阅读 332

收藏
2020-05-17

共1个答案

小编典典

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

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

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

当您显示一条有用的消息gem install mysql2。不幸的是,如果您在Bundler上安装宝石,Bundler会收到消息。这里是:

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

遵循这些说明可以为我解决问题。

参考链接

2020-05-17