MySQL: Skip INSERT / UPDATE statement that triggers error but show them in output I have a million of rows of customers to be imported via SQL dump. Customer data will be inserted into main table customer and child table customer_address

The dump contains the following SQL statements:

File: customer-dump.sql

BEGIN TRANSACTION;
INSERT INTO customer (firstname, lastname) VALUES ('John', 'Doe');
INSERT INTO customer_address (customer_id, city, country) VALUES (LAST_INSERT_ID(), 'New York', 'USA');
COMMIT;

BEGIN TRANSACTION;
INSERT INTO customer (firstname, lastname) VALUES ('Lorem', 'Ipsum');
INSERT INTO customer_address (customer_id, city, country) VALUES (LAST_INSERT_ID(), 'Chicago', 'USA');
COMMIT;

# So on for N no of customers


I am importing via CLI as:

mysql -u [user] -p [database] &lt; customer-dump.sql &gt; /tmp/customer-import-error.log


My Queries:


How to continue the script execution even if there is a failure in some rows?
How to show/log errors for failed rows?
Any advice on such massive import?
it is 2 different problem

1st is possible errors, for this You can use --force option

mysql -u user -p --force database &lt;


and 2nd is speed

for speed You can check server configuration and adjust it if necessary:


memory (innodb)
size of redo log file, default is too small, You can increase it


because You are already have dump file - no reason discuss about single transaction or group transactions.