繁体   English   中英

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

[英]Error when starting Rails server with MySQL

我在Windows 7的Ruby 2.0.0上运行Rails 4.0.3,并安装了DevKit(全部为x64)。 我已经使用subst X: "C:\\Program Files\\MySQL\\MySQL Server 5.6"安装了mysql2 gem subst X: "C:\\Program Files\\MySQL\\MySQL Server 5.6" ,然后gem install mysql2 --platform=ruby -- --with-mysql-dir=X:并且它已经安装精细。 然后,我用新的rails new mysql_testy创建了一个新应用,该应用运行良好,但是当我运行rails server ,出现以下错误:

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>'`

你们知道发生了什么吗?

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

但是,在此步骤之前,您可能必须重新安装指向连接器路径的全新MySQL2 gem: gem install 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"'

希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM