LOAD DATA LOCAL INFILE '/data/data.txt' IGNORE INTO TABLE test CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, sid, asf);
If a data field contains special characters like separators and escapes, execute OPTIONALLY ENCLOSED BY '"' to enclose the field with double quotation marks ("").
Example:
The following data field contains separators (,) and is enclosed with quotation marks:
"aab,,,bba,ddd"
If a data field contains quotation marks, the preceding method may not work. You can add a backslash (\) before each quotation mark (") in the field, for example, "aab,,,bba,ddd\"ddd\"bb,ae".
On some hosts running the Windows OS, the newline character of text files may be \r\n. The newline character is invisible, so you may need to check whether it is there.
For example, configure your client as follows:
mysql> set autocommit=0;
mysql> LOAD DATA LOCAL INFILE '/data/data.txt' IGNORE INTO TABLE test CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, sid, asf);
mysql> commit;
There are the following constraints on LOAD DATA syntax.