1553: Cannot drop index needed in a foreign key constraint
MySQLWhat does it mean?
You are trying to drop an index that is required by a foreign key constraint. InnoDB does not allow you to remove the index an FK relies on.
Why does it happen?
In InnoDB every foreign key requires an index on its referencing column(s). Dropping that index with DROP INDEX is rejected because it would leave the FK constraint without support. It usually comes up while reorganizing a table (index cleanup).
How to fix it
First drop the foreign key constraint, then drop the index: ALTER TABLE my_table DROP FOREIGN KEY fk_name; then DROP INDEX idx_name ON my_table; If needed, recreate the FK so that it relies on another suitable index. To list existing FKs: SELECT constraint_name, table_name FROM information_schema.key_column_usage WHERE referenced_table_name IS NOT NULL;
More from this engine
- 1129Host 'host' is blocked because of many connection errors
- 1194Table 'name' is marked as crashed and should be repaired
- 1615Prepared statement needs to be re-prepared
- 3948Loading local data is disabled; this must be enabled on both the client and server sides
- 1075Incorrect table definition; there can be only one auto column and it must be defined as a key
- 1055Expression not in GROUP BY (only_full_group_by)
- 1267Illegal mix of collations