在Windows 7和Windows上安装ruby 1.9.2p290(使用rubyInstaller)之后 将MySQL连接到它(我检查了它 它工作了)我安装了rails然后我在
上创建了一个项目“C:\用户\ Amiref \文件\网站\ simple_cms”
用这个命令:“rails new simple_cms -d mysql” 然后,当我使用“rails server”运行webrick时,我看到了这个错误 命令提示符:
"rails.bat :
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`require': Incorrect MySQL client library version! This gem was compile
d for 6.0.0 but the client library is 5.1.45. (RuntimeError)
At line:1 char:6
+ rails <<<< server
+ CategoryInfo : NotSpecified: (C:/Ruby192/lib/...
(RuntimeError):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in
`each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in
`block in require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in
`each'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in
`require'
from
C:/Users/Amiref/Documents/Sites/simple_cms/config/application.rb:7:in
`<top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:52:in
`require'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:52:in
`block in <top (required)>'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in
`tap'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:49:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
"
答案 0 :(得分:12)
最新的rails或ruby使用mysql-connector-c-6(libmysql.dll)编译mysql2-0.3.11-x86-mingw32,所以你应该使用6个客户端dll。
有一种简单的方法可以让RailsInstaller(Ruby1.9.2)使用mysql-connector-c-6:
然后运行rails服务器,一切正常。
答案 1 :(得分:2)
阅读错误消息。您的MySQL
gem需要版本6.0.0
,但您已安装5.1.45
。
答案 2 :(得分:2)
这是因为在您的项目中使用了gem(可能是mysql或mysql2),并且该gem的二进制文件是针对与您安装的版本不同的MySQL版本编译的。
mysql和mysql2 gems都取决于你在PATH中拥有libmysql.dll
库,这可能与用于构建这些宝石的库不同。
你最有可能使用Bundler来安装这些宝石,这会扼杀安装说明,了解在哪里获得特定版本的libmysql.dll
我建议您删除已安装在PATH中某处的libmysql.dll
上安装的mysql,mysql2 gems,并按照此处所述的说明进行操作:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
您可以跳过MySQL本身的安装,但要注意MySQL Connector / C二进制文件的使用(zip存档,而不是安装程序)以及如何安装它。
一旦你完成了mysql或mysql2 gem的安装(安装说明适用于两者),请更新你的软件包:
bundle check
因此它反映了本地安装的版本。
希望有所帮助。