Wednesday, March 4, 2009

Where did my MySQL server go?

If you're a rails developer who has rails app deployed in a shared hosting environment, you've probably dealt with the frustration of "unknown configurations" and smacked your head on the desk a few times trying to answer the question "how is this different from my development environment?" I've been there, and the latest episode in this saga is this humorous little error when using script/console:

ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone away

After a bit of Googling, I found this post which essentially says that if you're in a production environment, which I was, you need to specify script/console production to avoid this error. In my case, with Site5, the MySQL server "goes away" after 15 seconds or less. If anyone has a more in-depth explanation of this issue, I'm all ears, but for those of you looking for a quick fix, this should be it.

No comments: