I'm experiencing problems with a database on my server (Note: All other databases work fine).

Once I try to export it with mysqldump I get this error:

# mysqldump -u root -pXXXXXXXXX databasename > /root/databasename.sql

mysqldump: Couldn't execute 'show table status like 'apps'': Lost connection to MySQL server during query (2013)

Also, phpMyAdmin throws an error when selecting this database and immediately logs out. However, the web site which uses this database works fine. I can also execute SELECT statements on the table named "apps" from the MySQL shell.

I tried restarting the MySQL daemon as well as REPAIR DATABASE and REPAIR TABLE but the problem still persists. I had this problem before, then it disappeared somehow without me doing anything to resolve the issue. Now, the problem is back and I'm simply unable to create a backup of this database.

Used software

  • Debian 6.0.7 x64
  • MySQL 5.1.66-0

MySQL Version:

mysql> SHOW VARIABLES LIKE "%version%";
| Variable_name           | Value             |
| protocol_version        | 10                |
| version                 | 5.1.66-0+squeeze1 |
| version_comment         | (Debian)          |
| version_compile_machine | x86_64            |
| version_compile_os      | debian-linux-gnu  |

phpMyAdmin error message, when switching to the database

SELECT  `comment` 
FROM `phpmyadmin`.`pma_column_info`
WHERE db_name = 'databasename'
AND table_name =  ''
AND column_name = '(db_comment)'

MySQL said: 

#2006 - MySQL server has gone away
  • do you have a procedure or view that runs that query? – prodigitalson Jun 30 '13 at 3:08
  • Unfortunately not, but I posted the error message. That's all you will be seeing anyway. – bytecode77 Jul 1 '13 at 11:18

Most common reasons (and fixes) for the MySQL server has gone away (error 2006) are:

Server timed out and closed the connection. How to fix:


wait_timeout variable

in my.cnf configuration file is large enough.

On Debian:

 sudo nano /etc/mysql/my.cnf, 

set wait_timeout = 600 seconds

sudo /etc/init.d/mysql restart. 

Default value for wait_timeout might be around 28800 seconds (8 hours).

Second thing to check is

Server dropped an incorrect or too large packet. If mysqld gets a packet that is too large or incorrect, it assumes that something has gone wrong with the client and closes the connection. You can increase the maximal packet size limit by increasing the value of max_allowed_packet in my.cnf file.

On Debian:

  sudo nano /etc/mysql/my.cnf, 

  max_allowed_packet = 64M 


  sudo /etc/init.d/mysql restart.

Seems to be a problem at physical level accessing database files on disk.

I suggest to try a REPAIR TABLE before trying the mysqldump so you make sure database table files are . Check also mysql error log to make sure you are spotting the right issue. This will work for a MyISAM table. If you are working with InnoDB table try first to do an:

REPAIR TABLE tablename;

More info on command syntax here: http://dev.mysql.com/doc/refman/5.1/en/repair-table.html

  • I get The storage engine for the table doesn't support repair. – bytecode77 Jul 1 '13 at 13:27
  • I have edited my reply please try the new workaround. – mdiianni Jul 2 '13 at 9:20
  • When I execute the first query, I get ERROR 2013 (HY000): Lost connection to MySQL server during query – bytecode77 Jul 5 '13 at 17:25
  • Definitely it will help if you can provide a copy of your mysql error log. – mdiianni Aug 2 '13 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.