一 前言
今天遇到 如题所示问题,出错内容提示如下
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.MySQLSyntaxErrorException: Specified key was too long; max key length is 1000 bytes
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
二 解决方案
网上给出原因是元数据库mysql的编码问题,参见http://sishuok.com/forum/blogPost/list/5596.html
具体解决办法是
linux系统下,修改MySQL数据库默认编码的步骤为:
ü停止MySQL的运行
/etc/init.d/mysqlstart(stop)为启动和停止服务器 ,
üMySQL主配置文件为my.cnf,一般目录为/etc/mysql
var/lib/mysql/放置的是数据库表文件夹,这里的mysql相当于windows下mysql的date文件夹
ü当我们需要修改MySQL数据库的默认编码时,需要编辑my.cnf文件进行编码修改,在linux下修改mysql的配置文件my.cnf,文件位置默认/etc/my.cnf文件
找到客户端配置[client]在下面添加
default-character-set=utf8默认字符集为utf8
在找到[mysqld]添加
default-character-set=utf8默认字符集为utf8
init_connect='SETNAMESutf8'(设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)
修改好后,重新启动mysql即可,重新查询数据库编码可发现编码方式的改变:
>showvariableslike'character%';
+--------------------------+----------------------------+
|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/share/mysql/charsets/|
+--------------------------+----------------------------+
此时打开hive cli, 使用drop table 命令,成功执行。
附,参考资料《mysql修改编码》
本文解决了一起由MySQL编码问题引发的Hive执行错误问题,通过修改MySQL配置文件,确保了数据库编码一致性,最终使Hive操作得以顺利执行。
598

被折叠的 条评论
为什么被折叠?



