Ruby and MySQL lost connection weirdness
I had a bit of grief with a rails application connecting to a MySQL 4.1 DB.
I shared my insight over at MySQL+Database+access+problem on the Ruby on Rails Wiki.
Here’s what the error was and my solution is.
Lost connection to MySQL server during query was the error I was encountering.
Someone above mentioned passwords, and this was the cause for us.
Our development environment was not using a password to authenticate to a MySQL 4.1 installation. There were many explanations for â€lost connection†on the mysql site, but none that really it came down to passwords as others had mentioned.
In the /etc/my.cnf comment out the old password line:
#old_passwords=1
Then I changed the password again
mysql> set password for ‘bergo’@'localhost’ = password(‘WHATEVER’);
BTW – that’s not really my DB user …
Using the OLD_PASSWORD mysql command did not seem to work either.
Changing the database.yaml to user/password combo and it all worked a treat.
If you need old passwords I’m not sure what the solution is for you.
A little config gotcha .. no reason for us to be worried about old_passwords at all, it was a green fields app, but this is the way it’s installed by default. Strange though, MySQL admin had no trouble connecting under either configuration .. possible it tries both.