sqoop从mysql导入hive字符集的问题
Mysql都是使用utf8的字符集;所以这个与Mysql的配置无直接关系;但是可以通过修改Mysql上面的表默认字符集来解决,这个是不需要修改Hive配置的方法,快捷方便,不影响现有数据。
修改以下两张表即可;
alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
alter table TABLE_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8
sqoop的调整:
sqoop import \
--connect "jdbc:mysql://101.132.104.2:3306/educator?useUnicode=true&characterEncoding=utf-8" --username root --password 'Jcfm$#@*FDSvfs3124' \
--query 'select * from t_item_info_copy1 where itemId >= 1 and $CONDITIONS;' -m 1 \
--null-string 'null' --null-non-string 'null' \
--fields-terminated-by '\t' --lines-terminated-by '\n' \
--hive-drop-import-delims \
--target-dir /sqoop --as-textfile \
--delete-target-dir \
--hive-import \
--hive-database educator \
--hive-table yy