php - #1452 - Cannot add or update a child row, REFERENCES `eav_attribute`
I have read all the answer, however I am not a guru guy in things like that... I want to install magento database to my local computer host that runs on xampp, however I keep getting an error:
SQL query:
-
- -- Constraints for table
catalog_eav_attribute
-- ALTER TABLEcatalog_eav_attribute
ADD CONSTRAINTFK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID
FOREIGN KEY (attribute_id
) REFERENCESeav_attribute
(attribute_id
) ON DELETE CASCADE ON UPDATE CASCADE; MySQL said: Documentation1452 - Cannot add or update a child row: a foreign key constraint fails (
labas
.#sql-e94_2a
, CONSTRAINT
FK_CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID
FOREIGN KEY (attribute_id
) REFERENCESeav_attribute
(attribute_id
) ON DELETE CASCADE )
How could I solve this problem. Simple explanation would be awesome cause I have no clue in MySQL and SQL things at all.
Thanks in advance!
Answer
Solution:
You're getting this error because you're trying to add/update a row to
eav_attribute
that does not have a valid value for theattribute_id
field based on the values currently stored incatalog_eav_attribute
.It's likely that
attribute_id
you're trying to reference ineav_attribute
does simply not exist, therefor there's nothing to reference.To diagnose the specific cause we'd need to see more code.
Edit
I ran across this query (and modifed it) that can help you to see ids that can be causing the issue: