一 前言
今天遇到 如題所示問題,出錯內容提示如下
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修改編碼》