hive初始化mysql数据库报错

本文详细记录了在使用schematool初始化Hive元数据到MySQL过程中遇到的重复键错误,并提供了删除原有hive数据库以解决该问题的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@master bin]# schematool   -initSchema  -dbType  mysql
Metastore connection URL:	 jdbc:mysql://192.168.89.128:3306/hive?createDatabaseIfNotExist=true&useSSL=false
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Error: Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

错误原因是之前初始化过一次名字叫hive的数据库,因此再次初始化之前需要删除重名的hive数据库。

下面查看mysql数据库及删除hive数据库的过程:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| TestDB             |
| hive               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.22 sec)

mysql> drop database hive;
Query OK, 57 rows affected (3.07 sec)

删除之后,即可成功初始化

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值