hive初始化mysql数据库报错

版权声明:本文为博主原创文章,转载请注明出处! https://blog.csdn.net/ASN_forever/article/details/89716422
[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)

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

猜你喜欢

转载自blog.csdn.net/ASN_forever/article/details/89716422