How to skip row when importing bad MySQL dump
mysql -f -p < 2010-12-01.sql
the -f
(force) being the operative option here, worked for me.
Great tip. I did it a little different but same result.
perl -pi -e 's/INSERT INTO/INSERT IGNORE INTO/g' filename.sql
Following the advice from jmlsteele's answer and comment, here's how to turn the inserts into INSERT IGNORE
on the fly.
If you're importing from an sql
file:
sed -e "s/^INSERT INTO/INSERT IGNORE INTO/" < 2010-12-01.sql | mysql -p
If you're importing from a gz
file, just pipe the output from gunzip into sed instead of using the file input:
gunzip < 2010-12-01.sql.gz | sed -e "s/^INSERT INTO/INSERT IGNORE INTO/" | mysql -p
If you can make the dump again you could add --insert-ignore
to the command-line when dumping.
Or you can try using the mysqlimport command with --force
,which will continue even if it encounters MySQL Errors.