MySQL. Can’t create table errno 150

table1.field1 has no index defined on it. It is required to place a FOREIGN KEY constraint on field1. With this: CREATE TABLE IF NOT EXISTS `testdb`.`table1` ( `id` INT UNSIGNED NOT NULL , `field1` VARCHAR(50) NULL , KEY ix_table1_field1 (field1), PRIMARY KEY (`id`) ) ENGINE = InnoDB; Everything should then work as expected.