hive初始化數據庫mysql時出現Error: Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)


1. Hive初始化mysql數據庫

[root@sam02 hive1.2]# schematool -initSchema -dbType mysql

2. 出錯

Metastore connection URL:	 jdbc:mysql://sam03:3306/hive1?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 1.2.0
Initialization script hive-schema-1.2.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 !!
*** schemaTool failed ***

image

3. 解決方法

3.1 查看mysql數據庫

image


如上圖,發現mysql已經存在hive數據庫,之前已經初始化過mysql數據庫

3.2 方法1:刪除存在mysql的hive數據庫

mysql >drop database if exists hive;

3.3 方法2:修改hive的hive-site.sh的ConnectionURL


將jdbc:mysql://sam03:3306/hive?createDatabaseIfNotExist=true的hive改成其它名稱,如hive1


image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM