We have a CSV file with thousands of records in it. I want to import these rows into a MySQL table via phpmyadmin. here is the command used:
load data loca
For those interested, I had the same issue as described above but it had nothing to do with the LINES TERMINATED BY assignment, primary key violations or wrong character set.
I started getting this error after upgrading to MySQL 8 and my problem ended up being the column names I was sending via the col_name_or_user_var option. Originally I had extra columns in the import file that I wasn't using, and this caused no issue with the original implementation. After upgrading, however, I had to add variable entries for these columns to get it working and getting more than one row imported (I did not have access to change these columns in import.csv). With an import file like this:
FIELD_1, FIELD_2, FIELD_3, FIELD_4, FIELD_5
I had to go from:
LOAD DATA INFILE 'import.csv'
INTO TABLE tableName
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
(FIELD_1, FIELD_2, FIELD_3)
to:
LOAD DATA INFILE 'import.csv'
INTO TABLE tableName
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
(FIELD_1, FIELD_2, FIELD_3, @FIELD_4, @FIELD_5)