Import .SQL File Error - MySQL server has gone away

When we have to imported .SQL files big in one the date base, the classic method through phpMyAdmin is not a really good solution. Most of the times we hit a "reqest timeout"The easiest way is to connect the SSH / console to the database server, upload the .sql file, and then run the specific command lines for import.

mysql -u db_user -p -h localhost db_name < /path/sql_file.sql

If, after executing the command line and entering the database password, you get the error: "ERROR 2006 (HY000) at line 1281: MySQL server has gone away", most of the times it is overcoming a volume limit for imported files. It is possible that in standard MySQL configurations, the volume limit set in "max_allowed_packet" is lower than that of the file you want to import into the database.
The simplest solution is to edit the "my.cnf" file and set a limit to our needs. For example, if we want to import a .SQL file of 320 MB, then edit the file "my.cnf" and add the line:


After editing and saving, restart the mysql service on the server and resume the command line for import. everything should work smoothly.

Import .SQL File Error - MySQL server has gone away

About the author


Passionate about everything that means gadget and IT, I am pleased to write on from 2006 and I love to discover new things about computers and macOS, Linux operating systems, Windows, iOS and Android.

Leave a Comment