signed

QiShunwang

“诚信为本、客户至上”

错误1 -- Error: Duplicate key name ‘PCS_STATS_IDX‘ (state=42000,code=1061)

2021/4/26 20:18:19   来源:

当我们输入./schematool -initSchema -dbType mysql的时候,会出现以下错误:

Metastore connection URL:        jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:       root
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.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 ***

错误原因:以上错误经过查看linux中的mysql数据库已经创建了hive这个表。

解决办法:如果想重新初始化hive,把那个mysql中的hive数据库删掉,即可

重新初始化后截图如下: