Boris Budini

Kominoshja's mindscape

ERROR: Specified key was too long; max key length is 767 bytes

MySQL makes me pull my hairs out of my head

So the @infra team of Open Labs Hackerspace is migrating servers. While migrating I had to deal with one of the weirdest errors I had seen.

We’re pretty much stuck with MySQL on our servers due to platform dependencies, and I have forgotten nearly 95% of the reasons why I had migrated to PgSQL (TL;DR UTF8MB4)

Anyway… while migrating when we tried to import an exported database, we’d get ERROR 1071 (42000) at line 152: Specified key was too long; max key length is 767 bytes.

“What the hell is this?” we kept asking ourselves. Well.. It’s another of MySQL’s weird problems. It’s called a stated prefix limitation

I found the solution on this nextcloud post

Just run

use DATABASE_NAME;
set global innodb_large_prefix=on;
set global innodb_file_format=Barracuda;

Whatever MySQL.. whatever