4126
MySQLERRORNotableHIGH confidence

BLOB/TEXT column used without key length in index

Production Risk

Low — DDL fails; no data is affected.

Why it happens
  1. 1An index was created on a BLOB or TEXT column without specifying a prefix length.

Fix

Specify a key prefix length

Specify a key prefix length
ALTER TABLE t ADD INDEX idx_col (col(255));

Why this works

A prefix length tells MySQL how many characters to use from the beginning of the BLOB/TEXT column for indexing.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 4126 ER_BLOB_USED_AS_KEY2

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors