0

我想将我的 Ruby on Rails 应用程序与单独开发的 MySQL 数据库连接起来。对于这个连接,我使用了 development环境:

adapter: mysql
username: root  
password: ******  
host: 127.0.0.1
port: 3306   

当我尝试在 Rails 中建立 MySQL 连接时,它显示:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0-x86-mingw32/lib/mysql.rb:4:in `require': Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.5.9. (RuntimeError)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0-x86-mingw32/lib/mysql.rb:4:in `<top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
    from D:/registration/config/application.rb:7:in `<top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:53:in `require'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:53:in `block in <top (required)>'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in `tap'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

D:\registration>

此外,当我尝试我的 rake 命令时,它显示:

rake aborted!
Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.5.9.
D:/registration/config/application.rb:7:in `<top (required)>'
D:/registration/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

D:\registration>

如何连接到我的数据库?

4

1 回答 1

2

根据错误,您似乎使用的 gem 版本比 MySQL 客户端更新。

它说:

  • 您的 gem 已编译(创建)我的 sql 客户端版本 6.0.0。
  • 您实际的 my sql 客户端版本(在您的机器中)是 5.5.9。

您能否发布您的 MySQL gem 版本以及您的 MySQL 客户端版本?

将您的 MySQL 客户端升级到版本 6.0.0 应该可以解决此问题。

于 2012-12-10T11:13:00.847 回答