如何将mysql数据导入hive中

1.首先在hive中建表(尽量与mysql字段对应)

 2. 将mysql中的表导出 txt格式

 3.通过hadoop 上传到HDFS上

命令

hadoop dfs -put /home/hadoop/dim_station_trans_com_info.txt  /user/hive/external/tables/dim/dim_station_trans_com_info

前面为 hadoop文件地址 ,后面为HDSF文件地址。

4.查看HDFS上是否成功

 上传成功

4.将这个文件导入hive数据库

load data inpath '//user/hive/external/tables/dim/dim_station_trans_com_info/dim_station_trans_com_info.txt' into table dim_station_trans_com_info;

原文地址:https://www.cnblogs.com/dw-date/p/12769309.html