1071 🐬 MySQL

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

  1. Upgrade MySQL/MariaDB
  2. Use VARCHAR(191) for indexed utf8mb4 columns
  3. Laravel: Schema::defaultStringLength(191)

Detailed fix by platform

PHP

  1. php
    // AppServiceProvider::boot()
    Schema::defaultStringLength(191);

How to diagnose

  1. Version — SELECT VERSION()
  2. 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.