In my case, the problem was more like what was described in the first article you contacted.
Therefore, I just needed to make sure that:
Referenced Column is an index,- both
Referencing Column and Referenced Column are of the same type and length, i.e. both INT(10) values INT(10) , - both have the same settings not null , unsigned , zerofill , etc.
- both tables: InnoDB !
Here's the query pattern where the Referencing Column is equal to referencing_id and the Referenced Column is equal to referenced_id :
ALTER TABLE `db`.`referencing` ADD CONSTRAINT `my_fk_idx` FOREIGN KEY (`referencing_id`) REFERENCES `db`.`referenced`(`referenced_id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
Update 2016-03-13 : re-included in this issue, and I found my own answer. This time it did not help. It turns out that another table is still set to MyISAM, as soon as I changed it to InnoDB, everything worked.
source share