LOAD DATA INFILE: Invalid ut8mb4 character string

馋奶兔 提交于 2019-12-02 08:10:55

问题


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)

回答1:


As Rick James suggested, running SET NAMES utf8mb4; before the LOAD statement did the trick.



来源:https://stackoverflow.com/questions/41922029/load-data-infile-invalid-ut8mb4-character-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!