Save data into mysql from hive hadoop through sqoo

2019-06-11 13:43发布

问题:

I have my data store into hive table. i want to transfer hive tables selected data to mysql table using sqoop.

Please guide me how to do this?

回答1:

check out the sqoop guide here



回答2:

You need to use sqoop export, here is the example

sqoop export --connect "jdbc:mysql://quickstart.cloudera:3306/retail_rpt_db" \
   --username retail_dba \
   --password cloudera \
   --table departments \
   --export-dir /user/hive/warehouse/retail_ods.db/departments \
   --input-fields-terminated-by '|' \
   --input-lines-terminated-by '\n' \
   --num-mappers 2 

sqoop export to export data to mysql from Hadoop.

  1. --connect JDBC url
  2. --username mysql username
  3. --password password for mysql user
  4. --table mysql table name
  5. --export-dir valid hadoop directory
  6. --input-fields-terminated-by column delimiter in Hadoop
  7. --input-lines-terminated-by row delimiter in Hadoop
  8. --num-mappers number of mappers to process the data