Getting MYSQL Error: “Error Code: 2006 - MySQL ser

2019-02-04 09:12发布

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?

11条回答
等我变得足够好
2楼-- · 2019-02-04 09:41

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

查看更多
狗以群分
3楼-- · 2019-02-04 09:47

Show your mySql Variables

  • show variables like 'max%'

  • set global max_allowed_packet={PacketRANGE}; // like this 10485760;

  • show global variables like 'max_all%';

Enjoy Your Coding here

查看更多
Lonely孤独者°
4楼-- · 2019-02-04 09:49

Here's an alternative to editing my.cnf file. You can set the MySQL global variables value via logging into the MySQL server.

You can check the list of all the MySQL Global Variables and their values with the following command:

$> mysqladmin variables -u YourMysqlUsername -p

You can also check for these variables value by first logging into MySQL server:

$> mysql -u YourMysqlUsername -p

mysql> SHOW VARIABLES;

To check specific variable value:

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';

To solve MySQL Server Gone Away error, you need to increase the value of max_allowed_packet variable.

mysql> SET GLOBAL max_allowed_packet=1072731894;
mysql> quit

Now, when you again login to MySQL and check for the max_allowed_packet value, you should see the updated value.

$> mysql -u YourMysqlUsername -p

mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+------------+
| Variable_name      | Value      |
+--------------------+------------+
| max_allowed_packet | 1072731136 |
+--------------------+------------+
1 row in set (0.00 sec)
查看更多
淡お忘
5楼-- · 2019-02-04 09:50

I tried all the solutions and nothing worked
I use the workbench to remotely connect hostgator
I realized that mysql server hostgator was the 5.5 version and in my workbench is set up to version 5.6
when I set the workbench to 5.5 he started to work

edit/preferences/mysql/default target version
enter image description here

查看更多
时光不老,我们不散
6楼-- · 2019-02-04 09:51

AS mentioned by Tudor in his reaction:

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

You need to change the maximum execution time and size you can use the following commands to do so:

SET GLOBAL wait_timeout = 6000;
SET GLOBAL max_allowed_packet= 64M;

They are sql commands so you can execute them like noramal commands.

查看更多
登录 后发表回答