MySQL InnoDB Foreign Key Error
From zen2
I was getting Error 1005 "can't create table" ... errno 150 when trying to create a foreign key using the following
ALTER TABLE `user` ADD CONSTRAINT FOREIGN KEY (`group_id`) REFERENCES `group` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
What I needed to do to fix it was to create an index on group_id in the user table. Also if you get error 1452 make sure you don't already have fields filled which would otherwise be invalid.
Delete a Foreign Key
Get the Key Name from the bottom of an export, then
ALTER TABLE page_titles DROP FOREIGN KEY 0_172
