title: com.mysql.jdbc.PacketTooBigException
body: <p>I am storing images in MYSQL.</p>
  
  <p>I have table as </p>
  
  <pre><code>CREATE TABLE myTable (id INT, myImage BLOB);
  </code></pre>
  
  <p>When I am trying to insert <code>4.7MB</code> file, I am getting exception as </p>
  
  <pre><code>com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4996552 &gt; 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
  </code></pre>
  
  <p>I believe this is related to image size only. Is there any other variable type that I can use?</p>
  
  <hr>
  
  <h2>Update 1</h2>
  
  <p>As per older SO question, I also tried with <code>MEDIUMBLOB</code> but still I am getting same error.</p>
  
  <p><strong><em><a href="https://stackoverflow.com/a/624376/1066828">Adding Image to a database in Java</a></em></strong></p>
  
  <hr>
  
  <h2>Update 2</h2>
  
  <p>At the start of the project, I execute below query and everything is working now</p>
  
  <pre><code>SET GLOBAL max_allowed_packet = 1024*1024*14;
  </code></pre>