Mysql – Lost connection to MySQL server during query

MySQL

I am trying to import our old database into a new databsae on our test server however I keep coming accross this error:
"Lost connection to MySQL server during query".

As you can see below I have tried starting the server with increased values for read timeout and wait timeout. Plus I
have increased max_allowed_packet = 1024M

[root@DB-01 alexl]# /etc/init.d/mysql start
Starting MySQL (Percona Server). SUCCESS! 
[root@DB-01 alexl]# mysql -hlocalhost magento < magento.sql
ERROR 2013 (HY000) at line 15235: Lost connection to MySQL server during query

The sql file is ~7gig but need it all.

Any help is appreciated.

+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| delayed_insert_timeout      | 300      |
| have_statement_timeout      | YES      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 6000     |
| net_write_timeout           | 6000     |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 3600     |
| thread_pool_idle_timeout    | 60       |
| wait_timeout                | 28800    |
+-----------------------------+----------+

| max_allowed_packet          | 1024M    |

Best Answer

The value of max_allowed_packet is too small. You can overwrite it in an import by running mysql --max_allowed_packet=7500M magento < magento.sql or by editing the my.cnf file and restarting MySQL as explained here.