views:

3617

answers:

7

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
+1  A: 

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.

Topher Fangio
good idea about sqlite, but unfortunately, neither that works :\ see http://stackoverflow.com/questions/1557414/ruby-on-rails-sqlite-problem-on-windows-7-x64
Darth
@Darth - Man, that sucks. I have never had problems with SQLite. My guess is that is has something to do with 64-bit or with Windows 7, and I am on a Mac, so I can't really do any more testing. There are some other databases that Rails supports. To get you going, you might try one of them.
Topher Fangio
@Topher Fangio: Well you are unfortunately right about the Win7. The problem with sqlite was that I didn't get error about missing dll, which does show on Vista, but Win7 somehow didn't show anything (http://stackoverflow.com/questions/1557414/ruby-on-rails-sqlite-problem-on-windows-7-x64). Right now I'm working with SQLite on development, which works really nice, because my production server is on Linux VPS, so there is no problem. I have even more problems with image processing, which is also full of bugs on Vista x64 :( I guess this is one of the times, that make people switch OS :)
Darth
@Darth Sorry to hear that it doesn't work, but I have come to expect that from Windows. On the flip side though, my Mac went on the fritz and Java wouldn't load. After reinstalling, I finally figured out that it was a "corrupt" file in my home directory, so I guess every OS has it's quirks.
Topher Fangio
+19  A: 

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.

KandadaBoggu
awesome, it works :) (on both Win7 and Vista machine) ... you saved my life, thx very much
Darth
Thank you! I have been unable to do rails development on windows because of this. Everything is better now.
CaptnCraig
Just FYI, the PATH referenced above is (by default) : C:\Program Files\MySQL\MySQL Server 5.1\bin\libmySQL.dllRename that file and replace it with the file described above.
aronchick
awesome, thanks!
Paul
Thanks, but what happens with the next upgrade of Rails (or MySQL)? Do we need to keep track of random DLLs we need to drop here and there to get this to work? Seems like a hack to me. I'm new to RoR, and really want to experience the benefits I've heard so much about (coming from the C#, .NET world). I understand from a high-level the benefits of an open source, light-weight language and framework (compared to Microsoft's stack), but some of the solutions to weird problems I'm researching seem very "random." Is it me? ;)
Mark Freedman
Praise GOD. This solution works for me. Been battling with this for a while, and this got it working...just as I was about to give up :)
marcamillion
A: 

Could this be related to http://stackoverflow.com/questions/1966124/ruby-on-rails-win7-x64 ? If so, what was the fix again (couldn't figure it out from the first answer) ?

Dr1Ku
+1  A: 

Hi I am Sukumaran. 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]

A: 

This still doesnt work for me. I put the one from instant rails into programfiles/mysql/mysql server 5.1/bin

but when i do rake db:migrate i get the same error: !!! 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 a valid Win32 application. - C:/Ruby_1.8.6/lib/ruby/gems/1.8/ge ms/mysql-2.8.1-x86-mingw32/lib/1.8/mysql_api.so

(See full trace by running task with --trace)

A: 

This worked for me also. Thank you!

sam
A: 

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.

Amit