Time for action – importing Hive data into MySQL
Regardless of these limitations, let's demonstrate that, in the right situations, we can use Sqoop to directly export data stored in Hive.
- Remove any existing data in the employee table:
$ echo "truncate employees" | mysql –u hadoopuser –p hadooptest
You will receive the following response:
Query OK, 0 rows affected (0.01 sec)
- Check the contents of the Hive warehouse for the employee table:
$ hadoop fs –ls /user/hive/warehouse/employees
You will receive the following response:
Found 1 items … /user/hive/warehouse/employees/part-m-00000
- Perform the Sqoop export:
sqoop export --connect jdbc:mysql://10.0.0.100/hadooptest --username hadoopuser –P --table employees \ --export-dir /user/hive/warehouse/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.