MySQL server has gone away

*Warning*: MySQL server has gone away

If you get the error message ” *Warning*: MySQL server has gone away”, that means your Php or Perl/cgi powered application has not passed a query for a while. The connection to MySQL times out. To start up a new and simple query session, select a table within the database of that application via PhpMyAdmin.

If that does not help, you need to tweak MySQL conf file. Using your favorite Linux text editor such as: vi or pico, open MySQL conf file “/etc/my.cnf”.

vi /etc/my.cnf

Set the following values for these two variables:


If these values do not help, you can increase them.

Then restart MySQL. This command will restart MySQL daemon on most generic Linux servers:
/sbin/service mysqld restart

If you do not have a my.cnf file, create a new one. The local path on most generic Linux servers is: /etc/my.cnf

To view MySQL variables and their current values, run the following command at the prompt:

/usr/bin/mysql -uroot -pYOUR_ROOT_PASSWD

Then, run the following command (one single line) at MySQL prompt:

mysql> show global variables like ‘%timeout%’;

Which will show a result like this:

| Variable_name | Value |
| connect_timeout | 5 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| interactive_timeout | 28800 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 28800 |
9 rows in set (0.00 sec)

As mentioned earlier, you can change the values of the connect_timeout and net_write_timeout. The higher the values are, the longer MySQL stays active and can process longer queries.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: