Import .SQL File Error – MySQL server has gone away

This tutorial solves the error that appears when importing through the order line of files .SQL. Import .SQL File Error – MySQL server has gone away.

When we have imported files .SQL big in one Date base, the classic method through phpMyAdmin It is not a good solution. Most of the time we hit a “reqest timeout“. Import .SQL File Error – MySQL server has gone away.

The simplest is to connect SSH / console to the server that holds the database, to upload to the file .sql and then to execute the specific command lines for import.

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

If after executing the order line and entering the password of the database, meet 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 imported files.

It is very possible that in the standard configurations of MySQL, the limits of the volum established in “max_allowed_packet” Be smaller than that of the file you want to import into the database.

The simplest solution is to edit the file “my.cnf” and to establish a limit suitable for our needs. For example, if we want to import a file .SQL of 320 MB then we edit the file “my.cnf” and add the line:

 max_allowed_packet=400M 

After editing and rescue, we restart mysql service on the server and resume the order line for import. Everything should work without import .SQL file error – MySQL server has gone away.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. Import .SQL File Error – MySQL server has gone away
Leave a Comment