Resolve MySQL Error 2013 (HY000)


MySQL is a relational database management system which is used widely all over the world to store and manage data properly in the database. It uses two storage engines for this purpose namely InnoDB and MyISAM which performs all the tasks for it. But at times while working with MySQL database people encounter several errors which are due to many unwanted reasons.

Of all MySQL errors, MySQL error 2013 (HY000) is the most annoying and frustrating error that a user can ever encounter while working with MySQL database.

MySQL error 2013 (HY000) is frustrating because it is unpredictable. It is because you can’t produce it again even after performing all the steps and actions which have invoked this error message. So, when it will come and when it will not it is not known to any one.

Some of the MySQL errors like 2002 (Server is not started), 1062 (Duplicate entry), error 2006 (Server has gone away) are easy to identify and solve but error 2013 is simple annoying. Some of the situations and researches has indicated that MySQL error 2013 (HY000) occurs due to the lost connection of the server in the midst of the query execution.

So, when this 2013 error occurs you need to check the status of MySQL database –

shell> mysql –u root –p –e “\s” | grep Uptime

The above mentioned command will give you the up time of the MySQL Server. If it displays less than 1min then the server must have gone down and started again. In this circumstance you need to look for the Status Variable wait_timeout. By default it is set to 28800 sec i.e. (8 hours) but it can be changed while starting the server. You need to change in the my.cnf file or by setting the parameter for “CLIENT_INTERACTIVE” in “mysql_real_connect()” and if it is less than a minute then there is problem in the query not syntactically but semantically.

Since producing this MySQL error 2013 again is really tough, so proper care should be taken while passing arguments to the queries or stored procedures and if there is some issue with the database or storage engines then MySQL Repair tool can be a great alternative to resolve the issue.