My Journey Upgrading MySQL 5.7 to 8.4 – and the Foreign Key Surprise
I recently had a project where I needed to upgrade a database from MySQL 5.7 to MySQL 8.4 . As with most MySQL upgrades, I had two options in front of me: Do an in-place upgrade , swapping the binaries and running mysql_upgrade . Go with a logical upgrade , using mysqldump to export everything and then import it into the new version. I decided to take the logical path . It felt safer for this use case, since it gives you a fresh environment and avoids any messy leftovers from the old version. So far, so good. I dumped my 5.7 database and began the import into MySQL 8.4. That’s when things went sideways. The Error That Stopped Everything The import was moving along nicely until I hit this: ERROR 6125 (HY000): Failed to add the foreign key constraint . Missing unique key for constraint 'my_foriegn_FK1' in the referenced table 'my_parent_table' . My first thought was: “Wait… what? This schema has been running in production for years without a p...