Intet andet, jeg prøvede, virkede for mig, inklusive at sikre, at min .csv blev gemt med UTF-8-kodning.
Dette virkede:
Når du bruger LOAD DATA LOCAL INFILE
, sæt CHARACTER SET latin1
i stedet for CHARACTER SET utf8mb4
som vist i https://dzone.com/ articles/mysql-57-utf8mb4-and-the-load-data-infile
Her er et fuldstændigt eksempel, der virkede for mig:
TRUNCATE homestead_daily.answers;
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE homestead_daily.questions;
SET FOREIGN_KEY_CHECKS = 1;
LOAD DATA LOCAL INFILE 'C:/Users/me/Desktop/questions.csv' INTO TABLE homestead_daily.questions
CHARACTER SET latin1
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(type, question, created_at, updated_at);
SELECT * FROM homestead_daily.questions;