Sqoop data export and import commands
1. import data from mysql to hive
Sqoop import -- connect jdbc: mysql: // localhost: 3306/sqoop -- direct -- username root -- password 123456 -- table tb1 -- hive-table tb1 -- hive-import-m 1
Here, -- table tb1 is a table in the mysql sqoop database, and -- hive-table tb1 is the name of the table imported to hive. You do not need to create a table first.
2. import data from hive to 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 '\ 001'
-- Table t4 is the name of the table imported to mysql. You must create a table first.
3. import data from mysql to hdfs
Sqoop import -- connect jdbc: mysql: // localhost: 3306/sqoop -- direct -- username root -- password 123456 -- table tb1-m 1
4. import data from hdfs to 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
Create a tb1 table in mysql.
When sqoop is used to import mysql Data to hdfs, the following error is reported:
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.
After query, caused by mysql JDBC driver bug, I use the mysql-connector-java-5.1.10-bin.jar version, after changed to the mysql-connector-java-5.1.25-bin.jar version of the NO PROBLEM
Implement data import between Mysql, Oracle, and HDFS/Hbase through Sqoop
[Hadoop] Detailed description of Sqoop Installation Process
Use Sqoop to export data between MySQL and HDFS Systems
Hadoop Oozie learning notes Oozie does not support Sqoop Problem Solving
Hadoop ecosystem construction (hadoop hive hbase zookeeper oozie Sqoop)
Full history of Hadoop learning-use Sqoop to import MySQL Data to Hive
Sqoop details: click here
Sqoop: click here
This article permanently updates the link address: