MySQL ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
An index on a VARCHAR is too long for the row format — classic with utf8mb4 VARCHAR(255) on MySQL 5.6/MariaDB 10.1.
Seen on:
MySQL
Meaning
utf8mb4 uses 4 bytes per character: 255 × 4 = 1020 bytes > 767. MySQL 5.7+ (DYNAMIC row format, large prefixes) allows 3072 bytes.
Common causes
- Old MySQL/MariaDB with utf8mb4 indexed VARCHAR(255)
- COMPACT row format
- Laravel default string length 255
⚡ Quick fix
- Upgrade MySQL/MariaDB
- Use VARCHAR(191) for indexed utf8mb4 columns
- Laravel: Schema::defaultStringLength(191)
Detailed fix by platform
PHP
- php
// AppServiceProvider::boot() Schema::defaultStringLength(191);
How to diagnose
- Version — SELECT VERSION()
- Column — Length × bytes per char
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026