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 tablecatalog_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: Documentation

1452 - Cannot add or update a child row: a foreign key constraint fails (labas.#sql-e94_2a, CONSTRAINT


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!




You're getting this error because you're trying to add/update a row toeav_attribute that does not have a valid value for theattribute_id field based on the values currently stored incatalog_eav_attribute.

It's likely thatattribute_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.


I ran across this query (and modifed it) that can help you to see ids that can be causing the issue:

SELECT c.attribute_id 
FROM catalog_eav_attribute c
LEFT JOIN eav_attribute e 
ON c.attribute_id = e.attribute_id
WHERE e.attribute_id IS NULL;

People are also looking for solutions to the problem: php - Handle session while form submission


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.