0

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.

3
  • What is your MySQL version? may you can find something useful on data directory\machinename.log or error.log.
    – Moshe L
    Nov 25, 2011 at 13:37
  • +--------------+ | version() | +--------------+ | 5.1.49-1-log | +--------------+ 1 row in set (40.16 sec)
    – John Smith
    Nov 25, 2011 at 13:40
  • What do your logs say?
    – symcbean
    Nov 3, 2022 at 18:01

1 Answer 1

0

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

1
  • 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, 2011 at 13:53

You must log in to answer this question.