Rails 2.2 and MySQL Problems

Rails 2.2 and MySQL Problems

<!-- finde_surligneconditionnel-->
by Huw Collingbourne
<!-- debut_surligneconditionnel -->And a fix...<!-- finde_surligneconditionnel-->
<!--end: cartouche / Title Block -->
<!-- Bug Mozilla http://bugzilla.mozilla.org/show_bug.cgi?id=200510 --><!--optional elements...-->
<!-- debut_surligneconditionnel -->

I just updated my Rails installation to the current release (2.2) earlier today - and, all of a sudden, my applications stopped working!

<!-- finde_surligneconditionnel-->
<!--intro/deck-->
<!-- debut_surligneconditionnel -->

In spite of the fact that Rails now defaults to using the SQLite 3 database, I prefer to use MySQL, just as I always have done in the past. And that’s where the problem lay.

When I tried to run my Rails application, this error message appeared in my browser:

no such file to load — mysql

This was baffling as I certainly have MySQL installed, the entries in my Rails database.yml specify adapter: mysql plus a valid MySQL database. So what the heck was the matter?

A bit of hunting around on the web soon convinced me that I was not alone in experiencing this problem. The general advice seems to be to install the MySQL gem as a separate operation. I don’t know why this is needed with Rails 2.2. whereas it wasn’t with earlier versions, but anyway, it seems to be. So, I opened up a command prompt and entered the following:

gem install mysql

When it had finished installing, I fired up my application again and had another try. The good news was that the ‘no such file to load’ message had gone. The bad news was that it had been replaced with this message:

The specified module could not be found. - c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.so

I checked the specified directory and, sure enough, the file, mysql.so was there. For some reason, however, it appears that Rails is unable to find a required MySQL dll. The best fix I’ve been able to find (ok, I admit this is clunky, but anyhow it works) is to copy libmySQL.dll from your MySQL binary directory (for example, C:\Program Files\MySQL\MySQL Server 5.0\bin) into the Ruby binary directory (for example, C:\ruby\bin). Restart your application (shut down and restart the server), then try running it again. For me, that fixes the problem.

I don’t know why this error crept into Rails 2.2 and I’m hoping it will be fixed in a future version. MySQL is an important database, Windows is an important operating system and the easier it is to use Rails with MySQL on Windows the better!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值