I'm using LOAD DATA INFILE to import some big tables (iTunes EPF).
However, the import fails with this error:
string(52) "Invalid utf8mb4 character string: 'אל נא תלך'"
The table is created like this:
CREATE TABLE `song-tmp` (
`song_id` int(11) NOT NULL DEFAULT '0',
`name` varchar(1000) DEFAULT NULL,
`title_version` varchar(1000) DEFAULT NULL,
`artist_display_name` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`song_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
This is the import query I'm using:
LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `song-tmp`
CHARACTER SET utf8mb4
FIELDS TERMINATED BY X'01'
LINES TERMINATED BY X'020a'
(@export_date, song_id, name, title_version, @search_terms, @parental_advisory_id, artist_display_name, @collection_display_name, @view_url, @original_release_date, @itunes_release_date, @track_length, @copyright, @p_line, @preview_url, @preview_length)
As Rick James suggested, running SET NAMES utf8mb4;
before the LOAD
statement did the trick.