chevron-up bell reply instagram twitter2 feed3 finder search-25px-p0

MySQL: ERROR 1071 (42000) at line: Specified key was too long; max key length is 767 bytes


When I was doing the development with a recent project, I found out this err:

See here is one of my model class with url as an unique string.

As UTF8 is three bytes per character by default to store a string, and key in mysql is just 767 bytes long in total. If the string is too long which cannot be used as a key as it will exceed the size. in this case, 1000 * 3 = 3000 > 767.

The solution can be:

  1. Remove the unique = True
  2. Use a combination, i.e. url1, url2