创建表的时候,comment说明字段包含中文,表成功创建成功之后,中文说明显示乱码
create external table movie( userID int comment '用户ID', movieID int comment '电影ID', rating int comment '电影评分', timestamped bigint comment '评分时间戳', movieName string comment '电影名字', movieType string comment '电影类型', sex string comment '性别', age int comment '年龄', occupation string comment '职业', zipcode string comment '邮政编码' ) comment '影评三表合一' row format delimited fields terminated by "," location '/hive/movie';
这是因为在MySQL中的元数据出现乱码
因为我们知道 metastore 支持数据库级别,表级别的字符集是 latin1
那么我们只需要把相应注释的地方的字符集由 latin1 改成 utf-8,就可以了。用到注释的就三个地方,表、分区、视图。如下修改分为两个步骤:
修改hive-site.xml配置文件
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://IP:3306/db_name?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8</value> <description>JDBC connect string for a JDBC metastore</description> </property>做完可以解决乱码问题
转载自:https://www.cnblogs.com/qingyunzong/p/8724155.html