hive解决注释中文乱码

1、进入数据库 Metastore 中执行以下 5 条 SQL 语句
(1)修改表字段注解和表注解
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;
(2)修改分区字段注解
alter table PARTITION_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8 ;
alter table PARTITION_KEYS modify column PKEY_COMMENT varchar(4000) character set utf8;
(3)修改索引注解
alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;

hive配置hive-site.xml报错
error parsing conf file:/root/export/servers/hive-1.1.0-cdh5.14.0/conf/hive-site.xml
org.xml.sax.SAXParseException; systemId: file:/root/export/servers/hive-1.1.0-cdh5.14.0/conf/hive-site.xml; lineNumber: 5; columnNumber: 133; The reference to entity “characterEncoding” must end with the ‘;’ delimiter.`

1.报错原内容
javax.jdo.option.ConnectionURL jdbc:mysql://IP:3306/db_name?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8 JDBC connect string for a JDBC metastore

2.改为
javax.jdo.option.ConnectionURL jdbc:mysql://IP:3306/db_name?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8 JDBC connect string for a JDBC metastore

这大概是由xml文件中的编码规则决定要这么变换。

在xml文件中有以下几类字符要进行转义替换:

hive解决注释中文乱码_第1张图片

你可能感兴趣的:(hive学习)