Mysql errno: 150 when creating a foreign key

If you receive a errno; 150 when creating a foreign key in mysql, you may have encountered one of following problems :

  • The type of your foreign key is not the same as the referencing key, e.g. BIGINT -> INT
  • One of the two tables does not have the InnoDB engine. You cannot add foreign keys to MyISAM tables, or referencing MyISAM tables.

If you need more info about the actual error that occured, you can execute following sql statement :

SHOW ENGINE INNODB STATUS

This will show you which foreign key gave the error (or about other errors for that matter) and some more info about possible causes.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>