简体   繁体   中英

MySQL driver for Rails in Windows 7 x64

I've got problem with connecting to MySQL database on my freshly installed Windows 7 machine. I'm getting this error when I try to migrate my database.

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install 
the mysql gem and try again: gem install mysql.
rake aborted!
193: %1 is not valid Win32 application - C:/Ruby/lib/ruby/gems/1.8/gems/mysql-2.8.1-x86-mswin32/lib/1.8/mysql_api.so

I currently have installed

ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
mysql version 5.0.86  for Win64
gem 1.3.1
mysql-2.8.1-x86-mswin32

而在Windows 7上运行的轨道,我的同事也有类似的问题,他不得不从一个替换的libmysql.dll(在PATH) InstantRails的

I spent hours trying to get MySQL and Rails to play nicely on Windows (albeit XP, both 32 and 64-bit versions). I finally gave up since my production box was running Linux (on which Rails and MySQL play very nicely) and just used SQLite 3 for development. No headaches to get it working and it runs fast enough for development purposes.

However, I did hear of some people that had luck replacing one of the DLLs provided by the gem with one provided by the official MySQL distribution. Also, some people simply didn't have this DLL at all which was causing problems. In the end, it didn't work for me, but hopefully you will have more luck.

For Rails or DataMapper or whatever to talk to MySQL you need a 32-bit driver in Rails\\bin. The driver is called libmysql.dll. Even if you have a 64-bit server you need a 32-bit driver.

64-bit driver will fail will ruby/gems/1.8/gems/do_mysql-0.10.2-x86-mingw32/lib/do_mysql/1.8/do_mysql.so: 193: %1 is not a valid Win32 application.

A wrong 32-bit version will crash with memory allocation error or something weird like that (suggested solution to take libmysql.dll from another project may not work with newer versions of MySQL).

I am new to this rails. I just have passed the same issue in vista. after downloading libmySQL.dll (in the PATH) with the one from InstantRails it starts working.

sukumaaar@gmail.com

解决这个问题的方法是简单地安装32位版本的mysql。

Fast forward to March 2012. I solved this problem on windows 7 x64) by renaming my Ruby\\b\\bin\\libmysql.dll and then copying libmysql.dll from C:\\Program Files (x86)\\MySQL\\MySQL Connector C 6.0.2\\lib\\opt to Ruby\\bin

There was a newer version of libmysql.dll at C:\\Program Files (x86)\\MySQL\\MySQL Workbench CE 5.2.37 but the gem didn't like the non 6.x version.

Could this be related to Ruby on Rails Win7 x64? ? If so, what was the fix again (couldn't figure it out from the first answer) ?

另一个对我有用的选择是下载32位版本的mysql for windows并保留libmysql.dll并将此DLL的位置添加到windows PATH。

Adding the libmySQL.dll from InstantRails to a dir in my path worked for me too. It's really sad that we have to do this sort of thing though. I'd like to see the gem, or MySql itself, install this DLL properly.

I'm running the current versions of everything on WinXP SP3: Ruby 1.9.2p0, MySQL 5.5, mysql 2.8.1. This issue is still present and to fix it I had to copy the Instant Rails libmysql.dll into my C:\\Ruby192\\bin directory. I initially copied the libmysql.dll file that came with MySQL 5.5 but that caused a seq fault!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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