4117
MySQLERRORNotableHIGH confidence
Foreign key cannot use this index type
Production Risk
Low — DDL fails; no data is affected.
Why it happens
- 1The FK column has a FULLTEXT or SPATIAL index but no B-tree index.
- 2The only available index on the FK column is not usable for FK lookups.
Fix
Add a regular B-tree index on the FK column
Add a regular B-tree index on the FK column
ALTER TABLE t ADD INDEX idx_fk_col (fk_col);
Why this works
A standard B-tree (default) index satisfies the FK enforcement requirement.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 4117 ER_FK_CANNOT_USE_INDEX
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev