ERROR 2006 (HY000) at line 43: MySQL server has gone away
Line 43 was where my giant INSERT was. Googling didn't help much. Importing a mysqldump-exported dump file worked fine, so after manually importing my data, I took a look at my Python-generated dump:
# wc asdf.sql
56 103353 2158554 asdf.sql
Versus the official MySQL dump:
# wc sql/rhel_errata_2012-06-24.sql
57 213 2025975 sql/rhel_errata_2012-06-24.sql
# wc sql/rhel_errata_2012-06-24.sql
57 213 2025975 sql/rhel_errata_2012-06-24.sql
Line 44 in the MySQL-generated dump was the extra line. It was another INSERT statement. The bulk_insert_buffer_size was way larger than my file, so what was wrong?
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| bulk_insert_buffer_size | 8388608 |
+-------------------------+---------+
1 row in set (0.00 sec)
Googling for (no quotes) "mysql maximum values in insert" (https://www.google.com/search?&q=mysql+maximum+values+in+insert) pointed me to the max_allowed_packet variable:
# mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
|Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
1048576 bytes is exactly 1MiB, so raising it to something larger than intended dump file size suffices:
# mysql -e "SET GLOBAL max_allowed_packet = 8388608;"# mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 8388608 |
+--------------------+---------+
Don't forget to add it to /etc/my.cnf for persistence.