ERROR 2006 (HY000): MySQL server has gone away以及2.配置MySQL使用UTF8字符集

在容器中运行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;

配置MySQL使用UTF8字符集

mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

set character_set_server=utf8;
set  character_set_database=utf8;

你可能感兴趣的:(ERROR 2006 (HY000): MySQL server has gone away以及2.配置MySQL使用UTF8字符集)