title: MySQL Error #1071 - Specified key was too long; max key length is 767 bytes
body: <p>When I executed the following command:</p>
  
  <pre><code>ALTER TABLE `mytable` ADD UNIQUE (
  `column1` ,
  `column2`
  );
  </code></pre>
  
  <p>I got this error message:</p>
  
  <pre><code>#1071 - Specified key was too long; max key length is 767 bytes
  </code></pre>
  
  <p>Information about column1 and column2:</p>
  
  <pre><code>column1 varchar(20) utf8_general_ci
  column2  varchar(500) utf8_general_ci
  </code></pre>
  
  <p>I think <code>varchar(20)</code> only requires 21 bytes while <code>varchar(500)</code> only requires 501 bytes. So the total bytes are 522, less than 767. So why did I get the error message?</p>
  
  <pre><code>#1071 - Specified key was too long; max key length is 767 bytes
  </code></pre>