MySQL 新 Rails 应用程序的“193:%1 不是有效的 Win32 应用程序”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1208029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"193: %1 is not a valid Win32 application" bug with a new Rails Application
提问by aronchick
I have a new rails application which I have created under Windows 7 by going into a directory and typing "rails newapp". The creation went fine, and when I access the root page, all is well. However, when I try to access a page that would access the database, I get this:
我有一个新的 rails 应用程序,我在 Windows 7 下通过进入一个目录并输入“rails newapp”来创建它。创作很顺利,当我访问根页面时,一切都很好。但是,当我尝试访问将访问数据库的页面时,我得到以下信息:
193: %1 is not a valid Win32 application.
In the developer.log. Mysql is running fine on my machine, and I have other applications which I have running in here in other directories, it's just this one that doesn't work. Any thoughts?
在 developer.log 中。Mysql 在我的机器上运行良好,我在其他目录中运行了其他应用程序,只是这个不起作用。有什么想法吗?
回答by aronchick
Here's the answer that worked for me. Turns out it was an issue of x64 vs. x32 issue and Rails 2.3.2.
这是对我有用的答案。原来这是 x64 与 x32 问题和 Rails 2.3.2 的问题。
The answer I got from here (http://osdir.com/ml/RubyonRailsTalk/2009-06/msg01775.html):
我从这里得到的答案(http://osdir.com/ml/RubyonRailsTalk/2009-06/msg01775.html):
In case anyone else has the same problem after a lot of struggling on my Windows XP x64 machine, with MySQL 5.1.30 (x64) and Rails 2.3.2 installed, this above suggestiong helped me. Download libMySql.dll from here (http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/) and putting it in ruby\bin solved the problem.
如果其他人在安装了 MySQL 5.1.30 (x64) 和 Rails 2.3.2 的 Windows XP x64 机器上苦苦挣扎后遇到同样的问题,上面的建议对我有帮助。从这里下载 libMySql.dll ( http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/) 并将其放入 ruby\bin 解决了问题。
回答by Geoff
Solved by following the directions on this blog here: http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
按照这里博客上的说明解决:http: //blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
which involves using the non installer version of the MySQL Connector http://dev.mysql.com/downloads/connector/c/
这涉及使用 MySQL 连接器的非安装程序版本http://dev.mysql.com/downloads/connector/c/
I could not get webrick to run on x64 Windows 7 system -- got the same error
我无法让 webrick 在 x64 Windows 7 系统上运行——得到了同样的错误
"193: %1 is not a valid Win32 application”
“193:%1 不是有效的 Win32 应用程序”
If I just replaced the file libmysql.dll (as suggested in posts above), I got a different error.
如果我只是替换了文件 libmysql.dll(如上面帖子中所建议的那样),则会出现不同的错误。
"Incorrect MySQL client library version!"
“不正确的 MySQL 客户端库版本!”
My Path set like this: C:\Ruby187\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Ruby187\lib\ruby\gems\1.8\gems\rails-3.1.1\bin
我的路径设置如下:C:\Ruby187\bin;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Ruby187\lib\ruby\gems\1.8\gems\rails-3.1.1\bin
(didn't need to change the path again)
(不需要再次更改路径)
回答by user243229
This error occurs if you have a file with name "Program" in the root of your drive. Say for example you are trying to execute "C:\Program Files\SomeApp\Bin\SomeExe.Exe" it tries to execute "C:\Program" if it exists. In some situations a file with this name get created if you forget to quote "C:\Program Files..." with some commandline commands. This of course also applies for you D: drive, etc.
如果您的驱动器根目录中有名为“Program”的文件,则会发生此错误。例如,假设您正在尝试执行“C:\Program Files\SomeApp\Bin\SomeExe.Exe”,它会尝试执行“C:\Program”(如果存在)。在某些情况下,如果您忘记在某些命令行命令中引用“C:\Program Files...”,则会创建具有此名称的文件。这当然也适用于您 D: 驱动器等。
This error often occurs if you try to start services, but may occur in other situations.
如果您尝试启动服务,通常会发生此错误,但在其他情况下可能会发生。
Simply deleting the file C:\Program or D:\Program etc. solves the problem.
只需删除文件 C:\Program 或 D:\Program 等即可解决问题。
回答by Piers C
Having run into multiple issues setting up MySQL with Rails on Windows x64 my recommendations are:
在 Windows x64 上使用 Rails 设置 MySQL 时遇到多个问题,我的建议是:
- Install the 32-bit version of MySQL, do not try to use the 64-bit version.
- Install into a path with no spaces, do not accept a default like "C:\Program Files\MySQL\MySQL Server 5.5\"
- Install the MySQL gem with an invocation similar to:
gem install mysql -- --platform=ruby --with-mysql-dir="D:\Programs\MySQL\MySQL-Server-5.5" --with-libmysqllib="D:\Programs\MySQL\MySQL-Server-5.5\lib\"
- Be sure to uninstall/reinstall the gem whenever you install a new version of MySQL.
- Make sure D:\Programs\MySQL\MySQL-Server-5.5\lib is included in your path, as well as D:\Programs\MySQL\MySQL-Server-5.5\bin. Make sure other copies of libmysql.dll are not being picked up from elsewhere on your path or your ruby installation directories.
- 安装32位版本的MySQL,不要尝试使用64位版本。
- 安装到没有空格的路径中,不要接受像“C:\Program Files\MySQL\MySQL Server 5.5\”这样的默认值
- 使用类似于以下内容的调用安装 MySQL gem:
gem install mysql -- --platform=ruby --with-mysql-dir="D:\Programs\MySQL\MySQL-Server-5.5" --with-libmysqllib="D:\Programs\MySQL\MySQL-Server-5.5\lib\"
- 每当您安装新版本的 MySQL 时,请务必卸载/重新安装 gem。
- 确保 D:\Programs\MySQL\MySQL-Server-5.5\lib 以及 D:\Programs\MySQL\MySQL-Server-5.5\bin 包含在您的路径中。确保没有从路径或 ruby 安装目录的其他地方获取 libmysql.dll 的其他副本。
This worked for me with mysql-5.5.15-win32, mysql-2.8.1-x86-mingw32 and Windows 7 x64.
这对 mysql-5.5.15-win32、mysql-2.8.1-x86-mingw32 和 Windows 7 x64 对我有用。
回答by Steven Bluen
Copy the file libmysql.dll from your MySQL installation directory and paste it into your Ruby installation's bin directory. You may need to download a zip archive from http://dev.mysql.com/downloads/mysql/if your MySQL installation directory doesn't already include the file libmysql.dll.
从 MySQL 安装目录复制文件 libmysql.dll 并将其粘贴到 Ruby 安装的 bin 目录中。如果您的 MySQL 安装目录尚未包含文件 libmysql.dll,您可能需要从http://dev.mysql.com/downloads/mysql/下载 zip 存档。
回答by Ricardo Trevisan
Using Ruby (1.8.7) with MySQL(5.5) on Windows 7 and also getting error 193. Copying the libmySQL.dllto ruby /bin worked fine for me.
在 Windows 7 上将 Ruby (1.8.7) 与 MySQL(5.5) 一起使用,并且还收到错误 193。 将libmySQL.dll复制到 ruby /bin 对我来说效果很好。
C:\Work\redmine-2.4.1\config\database.yml content: # Default setup is given for MySQL with ruby1.9. If you're running Redmine # with MySQL and ruby1.8, replace the adapter name with `mysql`. # Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end. # Line indentation must be 2 spaces (no tabs). production: adapter: mysql database: redmine host: localhost username: root password: "pwd@123" encoding: utf8