Jakub Arnold
Jakub Arnold

Reputation: 87230

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

Upvotes: 20

Views: 17642

Answers (10)

sympatric greg
sympatric greg

Reputation: 3179

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.

Upvotes: 1

octane097
octane097

Reputation: 11

The solution to this problem is to simply install the 32-bit version of mysql.

Upvotes: 1

dB.
dB.

Reputation: 4770

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).

Upvotes: 2

Jason
Jason

Reputation: 1138

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!

Upvotes: 0

Eivind
Eivind

Reputation: 56

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.

Upvotes: 0

Amit
Amit

Reputation: 1

Another option which has worked for me is to download the 32bit version of mysql for windows and just keep the libmysql.dll and add the location of this DLL to the windows PATH.

Upvotes: 0

my_ls_kumar
my_ls_kumar

Reputation: 11

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.

[email protected]

Upvotes: 1

Dr1Ku
Dr1Ku

Reputation: 2910

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) ?

Upvotes: 0

Harish Shetty
Harish Shetty

Reputation: 64363

My colleague had a similar problem while running rails on Windows 7. He had to replace the libmySQL.dll (in the PATH) with the one from InstantRails.

Upvotes: 51

Topher Fangio
Topher Fangio

Reputation: 20667

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.

Upvotes: 4

Related Questions