If you are using insert, the you can ignore errors using ignore error or on duplicate key update (preferable because it only ignores duplicate key errors).
If you are using load data infile, then you can use the ignore key word. As described in the documentation:
If you specify IGNORE, rows that duplicate an existing row on a
unique key value are discarded. For more information, see Comparison
of the IGNORE Keyword and Strict SQL Mode.
Or, do as I would normally do:
- Load the data into a staging table.
- Validate the staging table and only load the appropriate data into the final table.