Skip to content

Instantly share code, notes, and snippets.

@kkirsche
Created March 11, 2022 17:41
Show Gist options
  • Save kkirsche/24cf21fe5c3ba62b4c59e3ceffebb144 to your computer and use it in GitHub Desktop.
Save kkirsche/24cf21fe5c3ba62b4c59e3ceffebb144 to your computer and use it in GitHub Desktop.
Locating Database Errors

If you ever run into:

(1005, 'Can't create table `database_name`.`table_name` (errno: 150 "Foreign key constraint is incorrectly formed")

Run:

mariadb -e "SHOW ENGINE INNODB STATUS"

You're looking for:

------------------------
LATEST FOREIGN KEY ERROR
------------------------
2022-03-11 17:23:05 0x700003f4c000 Error in foreign key constraint of table `database_name`.`table_name`:
Create  table `database_name`.`table_name` with foreign key `fk_really_long_name_here` constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns.
------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment