1. Import data from MySQL into hive
Sqoop Import--connect Jdbc:mysql://localhost:3306/sqoop--direct--username root--password 123456-- Table Tb1--hive-table tb1--hive-import-m 1
Where--table tb1 is a table in the MySQL sqoop database,--hive-table tb1 is the name of the table that was imported into hive without having to build the table beforehand.
2. Import data from hive into 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 that is imported into MySQL and needs to be built in advance.
3. Import data from MySQL into HDFs
Sqoop Import--connect Jdbc:mysql://localhost:3306/sqoop--direct--username root--password 123456-- Table Tb1-m 1
4. Import data from HDFs into 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
It is also necessary to build the TB1 table in MySQL first
The following error was reported in using Sqoop to import data from MySQL into HDFs:
inch more queries.
Query, caused by MySQL JDBC driver bug, I use the Mysql-connector-java-5.1.10-bin.jar version, and then change to the Mysql-connector-java-5.1.25-bin.jar version, there is no problem.
Sqoop Data Export Import command