4112
MySQLERRORNotableHIGH confidence

Foreign key columns are incompatible

Production Risk

Low — DDL fails; no data is affected.

Why it happens
  1. 1The FK column and referenced column have different data types.
  2. 2Character set or collation mismatch between FK and referenced columns.
  3. 3Column length differs (e.g., VARCHAR(100) referencing VARCHAR(255)).

Fix

Align column definitions between FK and referenced columns

Why this works

Ensure both columns use the same data type, length, character set, and collation.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 4112 ER_FK_INCOMPATIBLE_COLUMNS

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

← All MySQL errors