mysql2 gem compiled for wrong mysql client library(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 客户端库编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mysql2 gem 为错误的 mysql 客户端库编译
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
