Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting MYSQL Error: "Error Code: 2006 - MySQL server has gone away"

I am getting following error, when I try to import MYSQL database:

Error Code: 2013 - Lost connection to MySQL server during queryQuery: Error Code: 2006 - MySQL server has gone away 

Can someone let me know what is wrong?

like image 276
meetpd Avatar asked May 19 '11 06:05

meetpd


People also ask

How do I fix error code 2006 MySQL server has gone away?

The MySQL server has gone away (error 2006) has two main causes and solutions: Server timed out and closed the connection. To fix, check that wait_timeout mysql variable in your my. cnf configuration file is large enough, eg wait_timeout = 28800.

How do you fix MySQL server has gone away?

Excerpt: “You can check whether the MySQL server died and restarted by executing mysqladmin version and examining the server's uptime. If the client connection was broken because mysqld crashed and restarted, you should concentrate on finding the reason for the crash.”

Why is MySQL not connecting to server?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

How do I show MySQL errors?

The SHOW COUNT(*) ERRORS statement displays the number of errors. You can also retrieve this number from the error_count variable: SHOW COUNT(*) ERRORS; SELECT @@error_count; SHOW ERRORS and error_count apply only to errors, not warnings or notes.


2 Answers

Investigation shows many solutions correctly talking about setting the max_allowed_packet and wait_timeout for mysql in my.cnf; small addendum that the default install of mysql on mac osx doesn't appear to include this file. You may first need to create it at /etc/my.cnf (this is only an issue if you're using the default install of mysql instead of a mamp stack or similar)

contents of /etc/my.cnf that corrected this issue for me below:

[mysqld] max_allowed_packet= 64M wait_timeout= 6000 
like image 174
Rafe Hatfield Avatar answered Sep 21 '22 00:09

Rafe Hatfield


Here you can read more about this error and various ways to avoid/solve it

From the docs:

The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection

like image 25
Tudor Constantin Avatar answered Sep 17 '22 00:09

Tudor Constantin