ERROR 1022 (23000)

I came across an error in MySQL when I tried to transfer the data from a remote database to my local database. 

 I was particular about not losing my data by any chance. Hence I manually took back up of the important tables before inserting into my local database. However still to be on a safer side, I renamed the existing table name and imported the exported data from the remote database. While doing so, I surfaced the below mentioned error.

 

Error Code : ERROR 1022 (23000) at line 27: Can't write; duplicate key in table

 

This actually means, you cannot reference the key with the same name in the same schema. I renamed the table name properly, however I did not change the key name. Recreating a different table with the same foreign key resulted me this error.

 

Solution:  Renamed the foreign key name as well. After which data was pushed successfully.


Print   Email