MySQL: Can't create table (errno: 150)
Solution 1:
From the MySQL - FOREIGN KEY Constraints Documentation:
If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the correct column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns Error 1005 and refers to Error 150 in the error message, which means that a foreign key constraint was not correctly formed. Similarly, if an ALTER TABLE fails due to Error 150, this means that a foreign key definition would be incorrectly formed for the altered table.
Solution 2:
Error 150 means you have a problem with your foreign key. Possibly the key on the foreign table isn't the exact same type?
Solution 3:
You can get the actual error message by running SHOW ENGINE INNODB STATUS;
and then looking for LATEST FOREIGN KEY ERROR
in the output.
Source: answer from another user in a similar question
Solution 4:
Data types must match exactly. If you are dealing with varchar types, the tables must use the same collation.