hive连MySQL数据库创建表时报错该怎么办,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
成都创新互联公司-专业网站定制、快速模板网站建设、高性价比市南网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式市南网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖市南地区。费用合理售后完善,十载实体公司更值得信赖。
1. 报错信息:
2018-06-01 14:44:20,644 ERROR [main]: DataNucleus.Datastore (Log4JLogger.java:error(115)) - Error thrown executing CREATE TABLE `TABLE_PARAMS`
(
`TBL_ID` BIGINT NOT NULL,
`PARAM_KEY` VARCHAR(256) BINARY NOT NULL,
`PARAM_VALUE` VARCHAR(4000) BINARY NULL,
CONSTRAINT `TABLE_PARAMS_PK` PRIMARY KEY (`TBL_ID`,`PARAM_KEY`)
) ENGINE=INNODB : Specified key was too long; max key length is 767 bytes
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:741)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:587)
at com.jolbox.bonecp.StatementHandle.execute(StatementHandle.java:254)
at org.datanucleus.store.rdbms.table.AbstractTable.executeDdlStatement(AbstractTable.java:760)
at org.datanucleus.store.rdbms.table.AbstractTable.executeDdlStatementList(AbstractTable.java:711)
at org.datanucleus.store.rdbms.table.AbstractTable.create(AbstractTable.java:425)
at org.datanucleus.store.rdbms.table.AbstractTable.exists(AbstractTable.java:488)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.performTablesValidation(RDBMSStoreManager.java:3380)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTablesAndValidate(RDBMSStoreManager.java:3190)
at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2841)
at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:122)
2. 解决方案:
在MySQL数据库修改“hive数据库”的编码,在MySQL下执行命令:alter database hive数据库 character set latin1;
hive启动后,MySQL数据库里面会创建指定的数据库,ruozedb是在hive.site.xml文件中的MySQL连接URL指定的数据库。
2.1 登录MySQL数据库查看Database:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| ruozedb |
| test |
+--------------------+
5 rows in set (0.00 sec)
2.2 在MySQL数据库执行如下操作:
mysql> alter database ruozedb character set latin1;
Query OK, 1 row affected (0.00 sec)
2.3 在hive里面执行创建脚本
hive> show databases;
OK
default
Time taken: 2.158 seconds, Fetched: 1 row(s)
hive> create table psn_info(id int ,name varchar(200),age int , tel varchar(20),email varchar(100));
OK
Time taken: 2.913 seconds
hive> show tables;
OK
psn_info
Time taken: 0.132 seconds, Fetched: 1 row(s)
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联的支持。