title: Can you increase max_allowed_packet from the client?
body: <p>I need to execute a SQL dump with very large extended inserts. I'm using the <a href="http://dev.mysql.com/doc/refman/5.5/en/mysql.html" rel="nofollow noreferrer">official command-line tool</a> in my computer to connect to a server in the LAN. The execution always dies:</p>
  
  <blockquote>
    <p>ERROR 2006 (HY000): MySQL server has gone away</p>
  </blockquote>
  
  <p>... and I'm fairly sure that it's due to a tiny <code>max_allowed_packet</code> setting:</p>
  
  <pre><code>mysql&gt; SHOW VARIABLES LIKE 'max_allowed_packet';
  +--------------------+----------+
  | Variable_name      | Value    |
  +--------------------+----------+
  | max_allowed_packet | 10485760 |
  +--------------------+----------+
  </code></pre>
  
  <p>There're lots of documentation on how to change the setting <strong>in the server</strong> but I wonder if it's possible to change it just for current connection, i.e., <strong>from the client</strong> side. I don't need a general solution, I'll be happy if it works for the command line tool.</p>
  
  <p>I've checked documentation and <a href="http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options.html#option_mysql_max_allowed_packet" rel="nofollow noreferrer">found this</a>:</p>
  
  <blockquote>
    <p><code>max_allowed_packet</code><br></p>
    
    <p>The maximum packet length to send to or receive from the server. (Default value is 16MB.) </p>
  </blockquote>
  
  <p>... and subsequently tried this:</p>
  
  <pre><code>mysql ^
      --max_allowed_packet=50M ^
      --compress ^
      --default-character-set=utf8 ^
      --skip-reconnect ^
      -h mysql.example.com -u foo -b bar
  </code></pre>
  
  <p>Result: all commands to read <code>max_allowed_packet</code> still report 10MB and server still goes away.</p>
  
  <p>Can you increase <code>max_allowed_packet</code> from the client side?</p>