Strong Like Bull
Strong Like Bull

Reputation: 11297

How to restore data from MYSQL dump without any duplicate key errors?

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

Upvotes: 2

Views: 8495

Answers (3)

altatof
altatof

Reputation: 11

i suggest you use the source command; it will not stop on duplicates. mysql -u myuser -pmypassword

use database mydatabase; source mysqlfile.sql; exit;

Upvotes: 1

R. Hill
R. Hill

Reputation: 3620

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.

Upvotes: 4

Sergey Eremin
Sergey Eremin

Reputation: 11080

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

Upvotes: 1

Related Questions