Sometimes when running MySQL in batch mode, it requires to ignore some MySQL errors which pops in between.
As an example, we can consider a scenario where thousands of inserts required to be done and the statements are saved in a file, suppose in indata.sql. But it may be the case that some records are already there in database which you’re trying to insert or you are importing large data for development/test purpose and you won’t bother much if some rows can be skipped. In normal case, MySQL will show error something like below and exit:
ERROR 1062 (23000) at line 6: Duplicate entry 'blablabla' for key 2
So, to ignore the error and keep the insertion process running, you need to supply extra command line argument “-f” while execution:
$ mysql -f -u root -p dbname < indata.sql
MySQL will certainly show the errors but not halt, instead keep execution of next statements.