Home > Database > Mysql Tutorial > How to Fix 'MySQL Server Has Gone Away' Error During Large SQL File Import?

How to Fix 'MySQL Server Has Gone Away' Error During Large SQL File Import?

DDD
Release: 2024-12-26 20:56:10
Original
334 people have browsed it

How to Fix

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:

  1. Open the MySQL configuration file (my.cnf):

    • On Windows: "C:ProgramDataMySQLMySQL Server 5.6"
    • On Linux (Ubuntu): /etc/mysql
  2. Add the following line to the file:

    max_allowed_packet=64M
    Copy after login
  3. Save the changes and restart MySQL.
  4. Now, attempt to source the SQL file again. The import should now complete successfully.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template