首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为错误的mysql2客户端库编译的mysql gem

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

Stack Overflow用户
提问于 2012-01-05 18:22:32
回答 6查看 57.7K关注 0票数 65

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

代码语言:javascript
复制
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)

我该如何纠正它呢?

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2012-02-28 12:06:09

我和你有同样的问题,或者至少症状是一样的。

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

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

当您使用gem install mysql2时,会显示一条有用的消息。不幸的是,如果你用Bundler安装gem,Bundler会吃掉消息。这就是它:

代码语言:javascript
复制
=========================================================================
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

按照这些说明,我就解决了这个问题。

Referenced link

票数 87
EN

Stack Overflow用户

发布于 2013-03-05 00:49:15

卸载和重新安装gem通常可以解决这个问题,而不需要手动下载和移动文件。在rails应用程序目录中:

代码语言:javascript
复制
> gem uninstall mysql2

You have requested to uninstall the gem:
    mysql2-0.3.11
database_cleaner-0.9.1 depends on [mysql2 (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled mysql2-0.3.11

> bundle install

Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Using rake (0.9.2)
Using i18n (0.6.1)
... <SNIP> ...
Installing mysql2 (0.3.11) with native extensions
... <SNIP> ...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
票数 101
EN

Stack Overflow用户

发布于 2012-01-09 17:39:01

如果您使用的是64位版本的mysql和32位版本的ruby,那么可以在http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/上查看此解决方案。

基本上你必须从mysql网站上下载一个连接器,然后用你下载的连接器编译mysql或mysql2。

对于Ruby 1.9.2:

代码语言:javascript
复制
gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

对于Ruby1.9.3:(显示mysql2变体)

代码语言:javascript
复制
gem pristine mysql2 -- --with-mysql-config=C:\mysql-connector-c-noinstall-6.0.2-win32    

请注意,对解压缩MySQL连接器/C的目录使用了正斜杠。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8740868

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档