Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Processing and Analysis of server has gone away problems in Mass data Import of mysql

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces mysql mass data import server has gone away problem processing analysis, hope to give you some additional and updated knowledge, if there are other problems to understand, you can continue to pay attention to my update article in the industry information.

Due to work needs, you need to import a sql of about 200M into the user library.

execution command

mysql> use userDatabase changedmysql> source /tmp/user.sql

MySQL server has gone away error occurred during import, data import failed.

The error message is as follows:

ERROR 2006 (HY000): MySQL server has gone awayERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect... Connection id: 11Current database: userERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect... Connection id: 12Current database: userERROR 2006 (HY000): MySQL server has gone awayERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect... Connection id: 13Current database: user

Initially thought it was a timeout, so increased connect_timeout and wait_timeout values.

The problem remains after re-execution.

Solution:

Check the profile, found max_allowed_packet parameter,

The official explanation is that increasing the max_allowed_packet parameter appropriately allows the system to allocate more extended memory to process large data from client to server.

View the value of mysql max_allowed_packet

mysql> show global variables like 'max_allowed_packet';+--------------------+---------+| Variable_name | Value |+--------------------+---------+| max_allowed_packet | 4194304 |+--------------------+---------+

You can see that it's 4M, and then it's 256M(1024*1024*256).

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)

After modification, import is executed, everything is normal, and the problem is solved.

Note:

Use the set global command to modify the max_allowed_packet value, which will expire after restarting mysql and revert to the default value.

If you want to restart without restoring, you can open my.cnf file and add max_allowed_packet = 256M.

This article explains how to solve MySQL server has gone away when importing large quantities of data from MySQL. Please pay attention to more related content.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report