数据库
首页 > 数据库> > mysql导入大批量数据出现MySQL server has gone away的解决方法

mysql导入大批量数据出现MySQL server has gone away的解决方法

作者:互联网

mysql导入大批量数据出现MySQL server has gone away的解决方法
<pre>

mysql> show global variables like 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+-
</pre>
可以看到是4M,然后调大为256M(1024*1024*256)
<pre>
mysql> set global max_allowed_packet=268435456;
Query OK, 0 rows affected (0.00 sec)

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


注意:
使用set global命令修改 max_allowed_packet 的值,重启mysql后会失效,还原为默认值。

如果想重启后不还原,可以打开 my.cnf 文件,添加 max_allowed_packet = 256M 即可。

标签:gone,global,max,away,mysql,packet,set,allowed
来源: https://www.cnblogs.com/newmiracle/p/11865447.html