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

mysql2 gem compiled for wrong mysql client library(mysql2 gem 为错误的 mysql 客户端库编译)
本文介绍了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.

背景:我使用 Rails 3、mysql2 gem 和 MySQL 社区服务器版本 5.5.21(32 位)安装在我的 Windows 机器上.我从 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 客户端库编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)