I created a new project using the command:
我使用命令创建了一个新项目:
rails new simple_cms -d mysql
rails new simple_cms -d mysql
but when I try to launch the web server, this happens:
但是当我尝试启动Web服务器时,会发生这种情况:
C:\Users\johnny\Sites\simple_cms>rails server
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 193: %1 is not a valid Win32 application. - C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in `block in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler.rb:119:in `require'
from C:/Users/johnny/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
C:\Users\johnny\Sites\simple_cms>
Some version info just in case:
一些版本信息以防万一:
C:\Users\j\Sites\simple_cms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
C:\Users\j\Sites\simple_cms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
C:\Users\j\Sites\simple_cms>mysql --version
mysql Ver 14.14 Distrib 5.5.21, for Win64 (x86)
I've already searched the web looking for solutions, but none of them seem to work. Any help would be greatly appreciated, thank you.
我已经在网上搜索寻找解决方案,但它们似乎都不起作用。非常感谢任何帮助,谢谢。
2 个解决方案
#1
1
The problem is that the .dll file required to run mysql2 is not available, and, as a result, it does not recognize it as a valid Win32 application.
问题是运行mysql2所需的.dll文件不可用,因此,它不会将其识别为有效的Win32应用程序。
Download the "mysql-connector-c-noinstall-6.0.2" from the official repository. You may be asked to register, but it's free. Go to downloads, select "MySQL Connectors => Connector/C (libmysql)".
从官方存储库下载“mysql-connector-c-noinstall-6.0.2”。您可能会被要求注册,但它是免费的。转到下载,选择“MySQL Connectors => Connector / C(libmysql)”。
Unzip the downloaded file, then copy "libmysql.dll", located in the lib folder, to your Ruby/bin folder.
解压缩下载的文件,然后将位于lib文件夹中的“libmysql.dll”复制到Ruby / bin文件夹。
#2
0
I had similar issues once with my server on mac. I changed the version of ruby and it helped. Change the version of ruby to 1.8.7 and try if it works.
我在Mac上的服务器上遇到过类似的问题。我更改了ruby的版本并且它有所帮助。将ruby的版本更改为1.8.7并尝试它是否有效。
#1
1
The problem is that the .dll file required to run mysql2 is not available, and, as a result, it does not recognize it as a valid Win32 application.
问题是运行mysql2所需的.dll文件不可用,因此,它不会将其识别为有效的Win32应用程序。
Download the "mysql-connector-c-noinstall-6.0.2" from the official repository. You may be asked to register, but it's free. Go to downloads, select "MySQL Connectors => Connector/C (libmysql)".
从官方存储库下载“mysql-connector-c-noinstall-6.0.2”。您可能会被要求注册,但它是免费的。转到下载,选择“MySQL Connectors => Connector / C(libmysql)”。
Unzip the downloaded file, then copy "libmysql.dll", located in the lib folder, to your Ruby/bin folder.
解压缩下载的文件,然后将位于lib文件夹中的“libmysql.dll”复制到Ruby / bin文件夹。
#2
0
I had similar issues once with my server on mac. I changed the version of ruby and it helped. Change the version of ruby to 1.8.7 and try if it works.
我在Mac上的服务器上遇到过类似的问题。我更改了ruby的版本并且它有所帮助。将ruby的版本更改为1.8.7并尝试它是否有效。