Home >Database >Mysql Tutorial >How to Fix 'MySQL Server Has Gone Away' Error During Large SQL File Import?
Troubleshooting "MySQL Server Has Gone Away" Error during SQL File Import
When attempting to import a large SQL file containing INSERT queries, you may encounter the persistent error "ERROR 2006 (HY000): MySQL server has gone away." Despite restarting MySQL and manipulating the table/database, the issue persists.
The root cause of this error lies in the interplay between the file size and the MySQL server's max_allowed_packet setting. Your file size is 79512 bytes, while the max_allowed_packet is set to 1048576 bytes. This means that the size of the SQL file exceeds the maximum allowed packet size.
To resolve this issue, you need to increase the max_allowed_packet setting in the MySQL configuration file.
Steps:
Open the MySQL configuration file (my.cnf):
Add the following line to the file:
max_allowed_packet=64M
Additional Information:
This error can also occur when the columns have large values. In such cases, increasing the max_allowed_packet setting will resolve the issue.
The above is the detailed content of How to Fix 'MySQL Server Has Gone Away' Error During Large SQL File Import?. For more information, please follow other related articles on the PHP Chinese website!