I try to import data from a CSV to MySQL. For this I run mysql and log in with:
mysql -u USER -p --local-infile=1 DATABASE
and import data with:
LOAD DATA LOCAL INFILE '/home/USER/FILENAME.csv'
INTO TABLE TABLENAME
FIELDS TERMINATED BY ';'
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
First I thought everything is fine because the data was loaded and looked good so far but then I got some problems and found out that strings are limited to 32756 characters in my longtext column. So I'm sure I forgot something but couldn't find the answer until know :(
From the documentation:
If strict SQL mode is not enabled and you assign a value to a BLOB or TEXT column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated. For truncation of nonspace characters, you can cause an error to occur (rather than a warning) and suppress insertion of the value by using strict SQL mode.
LONGBLOB, LONGTEXT L + 4 bytes, where L < 2^32
My guess is that you're using a multibyte encoding and so are running into length problems. You've further not set strict SQL mode to error out when this is the case. Hope that helps and, as always, if you've further questions, do leave a comment.