使用MySQL启动Rails服务器时出错

使用MySQL启动Rails服务器时出错,mysql,ruby-on-rails,ruby,ruby-on-rails-4,webrick,Mysql,Ruby On Rails,Ruby,Ruby On Rails 4,Webrick,我在Windows7上的Ruby 2.0.0上运行Rails 4.0.3,并安装了DevKit(全部为x64)。 我使用subst X安装了mysql2 gem:“C:\Program Files\MySQL\MySQL Server 5.6”,然后使用MySQL dir=X:安装了mysql2--platform=ruby--。然后,我用railsnewmysql\u testy创建了一个新的应用程序,运行得很好,但是当我运行rails服务器时,我得到了以下错误: C:/Ruby200-x64

我在Windows7上的Ruby 2.0.0上运行Rails 4.0.3,并安装了DevKit(全部为x64)。 我使用subst X安装了mysql2 gem:“C:\Program Files\MySQL\MySQL Server 5.6”,然后使用MySQL dir=X:安装了mysql2--platform=ruby--。然后,我用
railsnewmysql\u testy
创建了一个新的应用程序,运行得很好,但是当我运行
rails服务器时,我得到了以下错误:

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in 'require': 193: %1 is not a valid Win32 application.   - C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in 'require'
from C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in 'tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in '<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'`
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in'require':193:%1不是有效的Win32应用程序。-C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so(加载错误)
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in''
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in'require'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in'block(2个级别)in require'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in'each'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in'block in require'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in'each'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in'require'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in'require'
来自C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in''
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in'require'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in'block in'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in'tap'
来自C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in''
从箱子/轨道:4:in“require”
从箱子/轨道:4:in`'`

你们知道发生了什么事吗?

不知道你们是否知道,但我也有同样的问题。我安装了32位sql连接器,从中复制了
libmysql.dll
文件,并将其粘贴到Ruby/bin文件夹中。打开新的命令提示符并能够连接到服务器

但在此步骤之前,您可能必须重新安装指向连接器路径的新MySQL2 gem:
gem安装MySQL2--platform=ruby--with mysql lib=“C:\mysql connector\mysql-connector-C-6.1.5-win32\lib”--with mysql include=“C:\mysql connector\mysql-connector-C-6.1.5-win32\include”--with mysql dir=“C:\mysql connector”“


希望这有帮助

这个问题的答案应该能解决您的问题:@rails4guides.com:在这个问题上,询问者安装了mysql2 gem的预编译二进制版本,而在这里它是使用DevKit安装的,用于为我的系统构建本机扩展。另外,当我按照我在网上找到的指南(比如你链接到的问题的第一个答案)尝试使用Ruby 1.9.3时,我甚至没有正确安装mysql2。问题似乎是Ruby是Win32,而MySql是Win64,这导致了一个不兼容错误。本文可能会解决您的问题:您确定我的Ruby是Win32吗?我显式安装了x64版本的Ruby。。。