MySQL Error number: MY-012034; Symbol: ER_IB_MSG_209; SQLSTATE: HY000 报错 故障修复 远程处理
文档解释
Error number: MY-012034; Symbol: ER_IB_MSG_209; SQLSTATE: HY000
Message: %s
Error number: MY-012034; Symbol: ER_IB_MSG_209; SQLSTATE: HY000
MySQL Error number MY-012034; Symbol ER_IB_MSG_209; and SQLSTATE HY000 is an error associated with the InnoDB storage engine. This error is specific to foreign key constraints.
Error Explanation
This error occurs when a foreign key constraint fails. Specifically, this error occurs when a value being added to a record of a InnoDB table violates the foreign key constraint.
Common Cases
This error is typically seen when creating a specific type of relationship between a couple of tables. When you have a “has many” relationship between a parent table and a child table, typically you create a foreign key constraint on the child table which references a specific value in the parent table’s unique ID. This error occurs when the value being added to the FK field of the child’s record does not exist in the parent.
Solution
The solution is to make sure that the foreign key value being added to the child record DOES exist in the parent table’s primary key field. This can be done programmatically or manually when inserting records into the table. If the record that must exist in the parent is not there, then you must create it.