尝试通过我的 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 客户端库编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!