hive 的drop table命令出错

一 前言

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

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修改编码》

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值