Ruby & MySQL Connection Problem
An interesting problem cropped up at work today. I wrote a script that uses our company database which is MySQL based. Everything has been running great. We were running MySQL on a Windows XP machine. Today, we cut over to a nice Dell 1950 server running Ubuntu Server 8.04.2 with MySQL server installed. As soon as we have the new server up and running with a restore of our data I test my script to make sure it is able to connect. To my dismay I find that it errors out saying that the MySQL object is returning nil (Ruby equivalent to null for you non-Ruby folks). I start thinking about the differences between the Windows and Linux versions of MySQL. I check that I can get onto the server using MySQL Client, which I can. After a bit more thinking and tinkering I finally figured out that Ruby was using an older version of the MySQL connector. Our Windows machine was running MySQL 4.3, and the new Ubuntu Server is running 5.0. One very important change took place between these versions, and that is how passwords are encrypted. A quick Google search revealed that you can force a user account to have a password encrypted using the older encryption format with a parameter. So, I created a new account just for my script with the necessary permissions, and like magic I’m able to connect.
As a side note, I haven’t abandoned my project. I have actually moved forward a fair bit. I have grabbed the necessary components, setup a bug tracking account, and setup an SVN repository for development. I have started development. I will keep you abreast of my progress. As of right now my tentative date for a first version is Saturday evening.
—————-
Now playing: Maroon 5 - Harder To Breathe
via FoxyTunes


Add A Comment