Linux – thesqldump isn’t able to export a specific database, phpMyAdmin crashes

debianlinuxMySQL

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

Best Answer

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:

check

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 

then

  sudo /etc/init.d/mysql restart.