Hive's comment (comment) Chinese garbled solution (pro-test effective)

Recently, someone in the group asked me the problem of garbled display in hive Chinese. Let's talk about how to set it.

When creating a table, the comment description field contains Chinese. After the table is successfully created, the Chinese description in desc displays garbled characters. As shown in the following figure:

We know that the metadata of hive is managed by mysql, so this is a problem of mysql metadata. Let's modify the character encoding

(1) Modify table field annotations and table annotations

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) Modify the annotation of the partition field

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) Modify index notes

alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;

Modify the hive-site.xml configuration file

<property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://IP:3306/db_name?createDatabaseIfNotExist=true&amp;useUnicode=true&characterEncoding=UTF-8</value>
    <description>JDBC connect string for a JDBC metastore</description>
</property>

Then look at the following structure

If there is something wrong, please correct me. If you have any questions, you can add QQ group: 340297350. More dry goods of Flink and spark can be added to the following planets

Guess you like

Origin blog.csdn.net/xianpanjia4616/article/details/90733124