Time for action – exporting data from MySQL into Hive

For this example, we'll export all the data from a single MySQL table into a correspondingly named table in Hive. You will need Hive installed and configured as detailed in the previous chapter.

  1. Delete the output directory created in the previous section:
    $ hadoop fs -rmr employees
    

    You will receive the following response:

    Deleted hdfs://head:9000/user/hadoop/employees
    
  2. Confirm Hive doesn't already contain an employees table:
    $ hive -e "show tables like 'employees'"
    

    You will receive the following response:

    OK
    Time taken: 2.318 seconds
    
  3. Perform the Sqoop import:
    $ sqoop import --connect jdbc:mysql://10.0.0.100/hadooptest 
    --username hadoopuser -P
    --table employees --hive-import --hive-table employees ...

Get Hadoop: Data Processing and Modelling now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.