美文网首页
MySQL server has gone away

MySQL server has gone away

作者: lookphp | 来源:发表于2018-10-12 16:48 被阅读7次

    在新搭建的mysql数据库服务器中,使用navicate导入数据时,数据导入失败,提示MySQL server has gone away 。
    当查询的结果集超过 max_allowed_packet 也会出现这样的报错。定位方法是打出相关报错的语句。用select * into outfile 的方式导出到文件,查看文件大小是否超过 max_allowed_packet ,如果超过则需要调整参数,或者优化语句。

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

    修改参数:

    mysql> set global max_allowed_packet=1024*1024*16;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> show global variables like 'max_allowed_packet';
    +--------------------+----------+
    | Variable_name      | Value    |
    +--------------------+----------+
    | max_allowed_packet | 16777216 |
    +--------------------+----------+
    1 row in set (0.00 sec)
    --------------------- 
    

    参考文档:

    相关文章

      网友评论

          本文标题:MySQL server has gone away

          本文链接:https://www.haomeiwen.com/subject/bwygaftx.html