本文介绍了LOAD DATA INFILE:无效的ut8mb4字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用LOAD DATA INFILE导入一些大表(iTunes EPF).
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: 'אל נא תלך'"
创建表的方式如下:
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)
推荐答案
正如里克·詹姆斯(Rick James)所建议的那样,在LOAD
语句执行此操作之前运行SET NAMES utf8mb4;
.
As Rick James suggested, running SET NAMES utf8mb4;
before the LOAD
statement did the trick.
这篇关于LOAD DATA INFILE:无效的ut8mb4字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!