Suppose I try to create a table with a primary key that’s varchar(500), and MySQL complains the key length is longer than the maximum of 1000 bytes. 500 is less than 1000. What’s happening? In this article I’ll explain why I, not MySQL, am wrong. Plus, I’ll show you a tasty (yet apparently harmless) bug in MySQL.
Here’s a statement that will fail on my server:
create table test(c varchar(250), d varchar(250), primary key(c,d)); ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes Why does it fail?