Hive使用出现的问题1——分区表导入时 MetaException
Hive使用
- 建表语句:
create table t_user(id int, name string) partitioned by (country string) row format delimited fields terminated by ',';
- Load 数据加载语句
LOAD DATA local INPATH '/root/hivedata/5.txt' INTO TABLE t_user partition(country='USA');
进行分区数据加载出现如下错误:
3. 进入hive默认日志目录查看:vim /temp/root/hive.log
2020-08-15 13:13:31,024 ERROR [HiveServer2-Handler-Pool: Thread-30]: DataNucleus.Datastore (Log4JLogger.java:error(115)) - Error thrown executing ALTER TABLE `PARTITIONS` ADD COLUMN `TBL_ID` BIGINT NULL : Table 'hive.PARTITIONS' doesn't exist
java.sql.SQLSyntaxErrorException: Table 'hive.PARTITIONS' doesn't exist
4.解决方案:
(1)删除mysql中hive 数据库;
(2)hive的bin目录下schematool 命令初始化表:
./schematool -dbType mysql -initSchema
(3)重新在Hive中创建表 ,然后Load 加载数据
注意
本人使用的环境为hadoop2.0,hive2.6,jdk1.8,mysql8.0.20,mysql-connect-java.jar也是8.0.20
在配置hive-site.xml中配置时,驱动配置为com.mysql.cj.jdbc.Driver