Mysql Error 1005 - Foreign Key Contraint Woes

If you are trying to set up foreign key constraints in MySQL InnoDb table, and run into Error 1005, open up a mysql client on the command line and type show engine innodb status. Then scroll through the output until you reach:
------------------------ LATEST FOREIGN KEY ERROR ------------------------
This will give you more information about the error. The foreign key names have to be unique, so if you use something generic for the name, you may run into issues when setting up constraints on other tables. The other error I have experienced was trying to set the on delete action to set the field null, but null was not allowed on that field.

Posted In: mysql

Commentary