4118
MariaDBERRORNotableHIGH confidence

Foreign key column data type mismatch

Production Risk

Low — DDL fails; no data is modified.

Why it happens
  1. 1The FK column and the referenced column have different data types (e.g., INT vs BIGINT).
  2. 2Signed vs unsigned mismatch between FK and referenced integer columns.

Fix

Align the FK column data type with the referenced column

Align the FK column data type with the referenced column
ALTER TABLE child MODIFY fk_col BIGINT UNSIGNED;

Why this works

Matching the referenced column type exactly satisfies the FK type requirement.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 4118 ER_FK_COLUMN_MISMATCH

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

← All MariaDB errors