If you enjoy reading my blog, you could consider supporting me on Patreon.

Showing full MySQL foreign key errors

In case of a foreign key error when creating or altering a table, MySQL doesn't show the full message.

You can read the full message by executing the following query and inspecting the Status column.

show engine innodb status;
2018-02-13 11:12:26 0x70000b776000 Error in foreign key constraint of table table/#sql-7fa_247a:
 foreign key (`my_foreing_key`) references `table` (`id`)
   on delete cascade:
Cannot resolve table name close to:
   on delete cascade
Would you like to stay up to date about new content? Feel free to subscribe to my newsletter and follow me on Twitter. Noticed a tpyo? You can submit a PR to fix it.