Hive中文注释乱码问题解决

一般来讲,中文注释乱码问题是字符集导致的。

1.进入hive元数据库,查看字符集

(1)mysql uroot -pmysql123

(2)use hive;

(3)查看:

show variables like '%char%';
+--------------------------+-------------------------------------+
| Variable_name            | Value                               |
+--------------------------+-------------------------------------+
| character_set_client     | utf8                                |
| character_set_connection | utf8                                |
| character_set_database   | latin1                                |
| character_set_filesystem | binary                              |
| character_set_results    | utf8                                |
| character_set_server     | latin1                                |
| character_set_system     | utf8                                |
| character_sets_dir       | /opt/beh/core/mysql/share/charsets/ |
+--------------------------+-------------------------------------+

   show variables like '%colla%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+

2.修改字符集
(1)mysql下修改:

alter database hive default character set utf8;
ALTER DATABASE  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE columns_v2 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE columns_v2 CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

(2)修改配置文件/etc/my.cnf

vim /etc/my.conf

[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8
 
 
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

其他解决方案:
字符集问题 可进元数据库
刷:

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;
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;
alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;

你可能感兴趣的:(Hive中文注释乱码问题解决)