hive 的drop table命令出錯

來源:互聯網
上載者:User
一 前言

       今天遇到 如題所示問題,出錯內容提示如下

   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修改編碼》

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.