title: ERROR 2006 (HY000): MySQL server has gone away
body: <p>I get this error when I try to source a large SQL file (a big <code>INSERT</code> query).</p>
  
  <pre><code>mysql&gt;  source file.sql
  ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    2
  Current database: *** NONE ***
  
  ERROR 2006 (HY000): MySQL server has gone away
  No connection. Trying to reconnect...
  Connection id:    3
  Current database: *** NONE ***
  </code></pre>
  
  <p>Nothing in the table is updated.  I've tried deleting and undeleting the table/database, as well as restarting MySQL.  None of these things resolve the problem.</p>
  
  <p>Here is my max-packet size:</p>
  
  <pre><code>+--------------------+---------+
  | Variable_name      | Value   |
  +--------------------+---------+
  | max_allowed_packet | 1048576 |
  +--------------------+---------+
  </code></pre>
  
  <p>Here is the file size:</p>
  
  <pre><code>$ ls -s file.sql 
  79512 file.sql
  </code></pre>
  
  <p>When I try the other method...</p>
  
  <pre><code>$ ./mysql -u root -p my_db &lt; file.sql
  Enter password: 
  ERROR 2006 (HY000) at line 1: MySQL server has gone away
  </code></pre>