Fixing MySql “Can’t create table (errno: 150)”

I got this while trying to create a foreign key in MySql. Once you see the fix its obvious. My parent table’s primary key was declared as UNSIGNED while my child table wasn’t. Change one or the other to match and you’re all set. I really which the MySql people would sit down and take a moment to write out better error messages. Something as simple as “datatypes must match” would have really helped me.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.