【问题标题】:`require': Incorrect MySQL client library version`require':不正确的 MySQL 客户端库版本
【发布时间】:2013-08-16 06:04:38
【问题描述】:

当我运行 rails server 时,它会显示如下错误消息:

`require': Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.1.42. (RuntimeError)
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql-2.9.1-x86-mingw32/lib/mysql.rb:4:in `<top (required)>'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
        from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'

我安装了 Mysql 5.1 数据库。

在我的 gem 文件中我写了这个:

gem 'mysql'

然后运行捆绑安装

是什么导致了这个问题?

【问题讨论】:

  • mysql 是一个很老的 gem,用 mysql2 试试
  • @apneadiving ,在安装 mysql2 gem 时,出现以下错误。Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
  • 这里有一个关于该错误stackoverflow.com/questions/15816331/…的问题,

标签: mysql ruby-on-rails ruby gem scaffolding


【解决方案1】:

试试这个

添加你的 Gemfile

 gem 'mysql2'

然后进行捆绑安装,并在命令行运行此命令来安装这些包。

   sudo apt-get install mysql-client libmysqlclient-dev

在窗户上

将 libmysql.dll 从 mysql 安装文件夹复制到您的 Ruby bin 系统上的目录。

【讨论】:

  • 有没有相当于sudo的命令,我的是windows操作系统。
【解决方案2】:

我认为你应该尝试包含 mysql2 gem,在你的 gemfile 中添加:

gem 'mysql2'

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-04-26
  • 2011-12-04
  • 2012-05-28
  • 2016-06-01
  • 2015-10-20
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
相关资源
最近更新 更多