Jun

20

I was working with Rails on my local development server tonight and was running into the MySQL ‘Lost Connection’ error. I read a couple other posts of others having problems on Win32 systems and privilege issues, however I am running Linux and the suggested fixes weren’t going to work for me. Apparently, mySQL was not liking how Rails was sending the username and password when initiating the connection through the socket. Not exactly sure why, but in case someone else runs into the issue, the quick fix is to create a mySQL user without a password. Add it to your database.yml file and restart the WEBrick server.

I am running mySQL 4.1.11, another solution might be to upgrade to the latest mySQL release.


Comments

Name (required)

Email (required)

Website

Speak your mind

4 Comments so far

  1. Anonymous on June 21, 2006 9:48 am

    I have been running under windows with MySql 5 with no problems. Using Mongrel for the production server with loadbalacing behind Apache 2.0. Works a treat. And with Rmagick :o )
    Campbell Xsive.co.nz

  2. Fabrice on July 5, 2006 8:23 am

    Hi Mike,

    Thanks for the workaround!

    I have the same issue, very strange. Two machines (dev and prod). The prod app, running FC4 as operating system, only runs with the dev database (password protected)… To have the prod app talking to the prod DB then I have to use your solution…

    Thanks again ;-)
    Fabrice.

  3. Anonymous on July 18, 2006 10:23 am

    MySQL 4.1 changed the authentication protocol (it now uses a different type of password hash). If you upgraded from a previous version of mysql, chances are your passwords are still in the old format. Since rails knows about the new format and tries to authenticate with new style passwords, it is unable to connect. Obviously this can be solved by simply not using passwords. But if you need password protection, just recreate the passwords in the new format (using the PASSWORD() function, i.e. SET password = PASSWORD(’newpass’)). Don’t forget to flush privs.

  4. Chris Blackburn on January 13, 2007 6:45 pm

    Mike, thanks for the info. We spent several hours troubleshooting this stupid issue before finding your solution.

Linkroll

Recent Projects