简体   繁体   English

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

[英]Error when starting Rails server with MySQL

I'm running Rails 4.0.3 on Ruby 2.0.0 on Windows 7, and have installed the DevKit (all x64). 我在Windows 7的Ruby 2.0.0上运行Rails 4.0.3,并安装了DevKit(全部为x64)。 I've installed the mysql2 gem using subst X: "C:\\Program Files\\MySQL\\MySQL Server 5.6" and then gem install mysql2 --platform=ruby -- --with-mysql-dir=X: , and it installed fine. 我已经使用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:并且它已经安装精细。 I then created a new app with rails new mysql_testy which ran fine, but when I run rails server I get the following error: 然后,我用新的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>'`

Do you guys have any idea what's happening? 你们知道发生了什么吗?

Not sure if you figured it out yet, but I was having the same issue. 不知道您是否知道了,但是我遇到了同样的问题。 I installed the 32 bit sql connector, copied the libmysql.dll file from it and pasted it into Ruby/bin folder. 我安装了32位sql连接器,从中复制了libmysql.dll文件,并将其粘贴到Ruby / bin文件夹中。 Opened a new command prompt and was able to connect to the server. 打开一个新的命令提示符,并能够连接到服务器。

Before this step though you may have to reinstall a fresh MySQL2 gem pointing to the path of the connector: 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"' 但是,在此步骤之前,您可能必须重新安装指向连接器路径的全新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"'

Hope this helps 希望这可以帮助

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

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