我将Hive配置为使用mysql Metastore。它工作正常。
但是当我试图放弃一张桌子时,我会收到如下错误。
FAILED: Error in metadata: javax.jdo.JDODataStoreException: Error(s) were found while auto-creating/validating the datastore for classes. The errors are printed in the log, and are attached to this exception.
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
我做了一些研究,谷歌和official faq告诉我,更改mysql字符集设置将解决这个问题。
我的mysql设置如下
mysql> show variables like '%char%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
8 rows in set (0.02 sec)
我将所有字符集设置从utf8
更改为latin1
,character_set_filesystem
,character_set_system
,character_sets_dir
除外。
即使这样做,我在尝试删除表时仍会遇到相同的错误。
更糟糕的是,每当我创建一个新表时,mysql字符集设置将重置为utf-8
。
有人可以帮忙吗?
答案 0 :(得分:5)
问题是在hive-site.xml中它在下面的创建'hive'中使用了另一个数据库
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
</property>
将数据库名称更改为您已经在mysql中创建的'Metastore',如此
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true</value>
</property>
希望这可以解决我遇到同样问题的问题,我就这样解决了。 友情马图克