MySQL foreign key creation failed 1005 reasons summary

  • 2020-06-07 05:27:30
  • OfStack

1. Install mysql with InnoDB plugin

./configure --prefix=/usr/local/mysql --with-plugins=csv,innobase,myisam,heap,innodb_plugin

2. The column referenced in the main table cannot be found
3. The character encoding of primary and foreign keys is not 1
4. The foreign key field does not match the type of the field to be verified
5. MySQL supports foreign key constraints and provides the same functions as other DB, but the table type must be InnoDB, and non-ES13en storage engine will cause error.
6. There is no index in the column of the table that builds the foreign key.

Related articles: