hive 的drop table命令出错

来源:互联网 发布:对锐捷网络的了解 编辑:程序博客网 时间:2024/06/07 07:55

一 前言

       今天遇到 如题所示问题,出错内容提示如下

   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/mysql start (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='SET NAMES utf8' (设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)

修改好后,重新启动mysql 即可,重新查询数据库编码可发现编码方式的改变:

>show variables like '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修改编码》