Welcome 微信登录

首页 / 数据库 / MySQL / Sqoop数据导出导入命令

1. 将mysql中的数据导入到hive中sqoop import --connect jdbc:mysql://localhost:3306/sqoop --direct --username root --password 123456 --table tb1 --hive-table tb1 --hive-import -m 1其中--table tb1是mysql sqoop数据库中的一张表,--hive-table tb1是导入到hive中该表的名字,不需要事先建表。2. 将hive中的数据导入到mysql中sqoop export --connect jdbc:mysql://localhost:3306/sqoop --username root --password 123456 --direct --table t4 --export-dir /user/hive/warehouse/tb1/part-m-00000 --input-fields-terminated-by "01"--table t4是导入到mysql中表的名字,需要事先建表3. 将mysql中的数据导入到hdfs中sqoop import --connect jdbc:mysql://localhost:3306/sqoop --direct --username root --password 123456 --table tb1 -m 14. 将hdfs中的数据导入到mysql中sqoop export --connect jdbc:mysql://localhost:3306/sqoop --direct --table tb1 --username root --password 123456 --export-dir hdfs://localhost:9000/user/Hadoop/tb1/part-m-00000 -m 1同样需先在mysql中建立tb1表在用sqoop将mysql中的数据导入到hdfs中,曾报以下错误:java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@54b0a583 is still active. No statements may be issued when any streaming result sets are open and in use on a given connection. Ensure that you have called .close() on any active streaming result sets before attempting more queries.经查询,为mysql JDBC驱动bug所致,我用的是mysql-connector-java-5.1.10-bin.jar版本的,后改为mysql-connector-java-5.1.25-bin.jar版本的就没有问题了相关阅读:通过Sqoop实现Mysql / Oracle 与HDFS / Hbase互导数据 http://www.linuxidc.com/Linux/2013-06/85817.htm[Hadoop] Sqoop安装过程详解 http://www.linuxidc.com/Linux/2013-05/84082.htm用Sqoop进行MySQL和HDFS系统间的数据互导 http://www.linuxidc.com/Linux/2013-04/83447.htmHadoop Oozie学习笔记 Oozie不支持Sqoop问题解决 http://www.linuxidc.com/Linux/2012-08/67027.htmHadoop生态系统搭建(hadoop hive hbase zookeeper oozie Sqoop) http://www.linuxidc.com/Linux/2012-03/55721.htmHadoop学习全程记录——使用Sqoop将MySQL中数据导入到Hive中 http://www.linuxidc.com/Linux/2012-01/51993.htmSqoop 的详细介绍:请点这里
Sqoop 的下载地址:请点这里本文永久更新链接地址