在容器中运行MySQL,导入表中,出现如下错误:

ERROR 2006 (HY000): MySQL server has gone away

这个问题由于好几个方面引起,可以修改MySQL的配置文件my.cnf。也可以直接进入MySQL中查看相关的参数,进行更改,在重新导入相关的库或表,相关参数有:

mysql> show global variables like '%timeout';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 1024     |
| delayed_insert_timeout      | 300      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 30       |
| net_write_timeout           | 60       |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 3600     |
| wait_timeout                | 28800    |
+-----------------------------+----------+
12 rows in set (0.00 sec)

mysql> show global variables like 'max_allowed_packet';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| max_allowed_packet | 104857600 |
+--------------------+-----------+
1 row in set (0.00 sec)

修改参数有:

connect_timeout,wait_timeout

set global connect_timeout=1024;
set global wait_timeout=28800;
set global max_allowed_packet=1024102416;
最后修改:2021 年 04 月 19 日 02 : 54 PM
如果觉得我的文章对你有用,请随意赞赏