In my case the error was caused by the outdated schema, one column was originally varchar(50)
but the dump I was trying to import was created from a modified version of the schema that has varchar(70)
for that column (and some of the entries of that field where using more than 50 chars).
During the import some keys were truncated and the truncated version was not unique anymore. Took a while to figure that out, I was like "but this supposedly duplicated key doesn't even exist!".