MySQL: ERROR 1062 (23000): Duplicate entry '' for key 1
Blogs20112011-10-09
MySQL: ERROR 1062 (23000): Duplicate entry ” for key 1
I got the above error in bash script when loading MySQL data, and find the solution to avoid this issue:
If you get “Skipped records” using ”LOAD DATA LOCAL INFILE” copy the data file to the actual database server and do the load without the ”LOCAL” keyword. This will then stop when an error occurs, 9 times out of 10 it will be index issues and you will know why there are skipped records.
e.g. LOAD DATA LOCAL INFILE ‘myinfile.txt’; Query OK, 288168 rows affected (1 min 44.49 sec) Records: 494522 Deleted: 0 Skipped: 206354 Warnings: 0
LOAD DATA INFILE ‘/data/input/myinfile.txt’; Query OK, 252243 rows affected (0.02 sec) ERROR 1062 (23000): Duplicate entry ‘5935009001-2008-08-03 04:19:18’ for key 1
So always use ’LOCAL’ keyword when LOAD DATA INFILE.
