views:

22

answers:

2

Everytime I try restoring the dump, I get :

ERROR 1062 (23000) at line 10297: Duplicate entry 'spaß' for key 'PRIMARY'

I am trying to restore it using:

mysql -u root -ppassword database < 0719.sql
+1  A: 

you should truncate or drop the table in which you get duplicates

kgb
+1: That or check the dump to see why it has duplicate values...
OMG Ponies
surely there is a way to make MYSQL do the work for you, that is to ignore duplicates. The database dump is like a gazillion lines. Not to mention the character it is finding appears to be weird itself.
jini
mysql _must not_ do that because it would compromise data integrity. it's impossible to know which of the duplicates is right. it is db administrator's work.
kgb
@jini: most things you can do with a dump (using INSERT IGNORE instead of INSERT for instance) can be done when _making_ the dump, not when importing it. Don't blame the tool for an incorrect / ill-suited backup.
Wrikken
if you can not redump the db your only way might be to manually edit the dump and make it INSERT IGNORE or REPLACE instead of just INSERT
kgb
I did a dump using: mysqldump --single-transaction -u root -pxxxxxx-h database > /tmp/0719.sql. You mean to say I can modify that to clean my dump?
jini
the fact that you get duplicates might mean that you are trying to merge data form two separately changed databases... which is not a good idea;) but if you don't care about old data, you might open the dump in any text editor and change INSERT to REPLACE(i wouldn't call it fixing, but it will do what you want)... and if you really don't care about the old data, you should empty the table first! otherwise, if you want to keep the data safe, you will have to examine every duplicate _individually_
kgb
A: 

You could import the dump into a temporary table, than use an SQL statement to copy only rows from this temporary table which do are not found in the target table.

R. Hill