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 it is not a very good solution. Most of the time we run into a “reqest timeout"The easiest way is to connect SSH / console to the server holding the database, upload to the .sql file and then execute the specific command lines for import.

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

If after running the command line and entering the database password you encounter the error: "ERROR 2006 (HY000) at line 1281: MySQL server has gone away", most of the time it is about exceeding a volume limit for the imported files. It is very possible that in standard MySQL configurations, the volume limit set in "max_allowed_packet" will be 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 appropriate to our needs. For example, if we want to import a 320 MB .SQL file, then we edit the "my.cnf" file 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 gadget and IT, I write with pleasure on since 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment