Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I get a MySQL server has gone away error on a simple query.

mysql> select version();
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    1

A query such as select id from users limit 1; can also result in this error. Most search results are about inserts or imports so I'm not really sure what to do.

share|improve this question

migrated from stackoverflow.com Nov 26 '11 at 2:26

This question came from our site for professional and enthusiast programmers.

    
What is your MySQL version? may you can find something useful on data directory\machinename.log or error.log. –  Moshe L Nov 25 '11 at 13:37
    
+--------------+ | version() | +--------------+ | 5.1.49-1-log | +--------------+ 1 row in set (40.16 sec) –  John Smith Nov 25 '11 at 13:40

1 Answer 1

It's not the select, it very likely your interactive timeout setting. MySQL will shutdown idle connections after a period of time. So if you don't type anything for a while, MySQL will drop the connection. What you are seeing is an auto reconnect.

You can change your wait_timeout and interactive_timeout settings if you like. This is unlikely a problem in your code since it is never idle long enough for the connection to drop. Unless you have some long running code.

http://dev.mysql.com/doc/refman/5.1/en/gone-away.html

share|improve this answer
    
Well actually, I just opened mysql and that was my first query that I posted here. I'm using SSH and doing this with root access on both the server and mysql. –  John Smith Nov 25 '11 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.