MySQL "Specified key was too long" — Where Does the 3072-Byte Limit Come From?
Root causes of MySQL Error 1071, utf8mb4 4-byte multiplier, prefix indexing tradeoffs, generated hash columns for full uniqueness, and composite index limits.
Operational Verification & Reliability Metadata
The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.
▸Symptoms
ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytesThis error surfaces when creating an index on utf8mb4 columns where total byte representation exceeds the InnoDB limit of 3,072 bytes (or 767 bytes under COMPACT/REDUNDANT row formats).
| Character Set | Bytes / Char | 3072-Byte Boundary |
|---|---|---|
latin1 | 1 byte | 3,072 characters |
utf8mb3 | 3 bytes | 1,024 characters |
utf8mb4 | 4 bytes | 768 characters |
Composite indexes sum all column widths: two varchar(500) utf8mb4 columns equal 4,000 bytes, breaching 3,072 bytes.
▸Resolution Patterns
1. Prefix Indexing
ALTER TABLE uygulamalar ADD INDEX idx_ad (ad(191));2. Generated SHA-256 Column for Full Uniqueness
ALTER TABLE uygulamalar
ADD COLUMN ad_hash BINARY(32) GENERATED ALWAYS AS (UNHEX(SHA2(ad, 256))) STORED,
ADD UNIQUE INDEX uk_ad_hash (ad_hash);- •Companion Guide (PostgreSQL): PostgreSQL index row size exceeds maximum
- •Related Error: MySQL Incorrect string value utf8mb4
- •Engine Hub: MySQL Production Hub
Other Database Error Triage Playbooks
Other battle-tested diagnostic guides for high-severity database errors.
MySQL ERROR 1045 Access denied: root Password Reset Guide
Four causes of MySQL 1045, meaning of using password: YES/NO, and safe credential recovery via --init-file.
MySQL Deadlock ERROR 1213: Graph Analysis and Permanent Prevention
Root causes of MySQL 1213 deadlock, parsing LATEST DETECTED DEADLOCK output, gap lock concurrency issues, and resilient application retry design.
MySQL Lock wait timeout exceeded: Finding Blocking Sessions
Finding the blocking transaction using performance_schema, safe KILL decision matrices, and permanent locking reduction.