当前位置:   article > 正文

Sqoop数据导入 第3关:Mysql导入数据至Hive中_第3关:mysql导入数据至hive中

第3关:mysql导入数据至hive中

注意!如果重置了代码仓库请用以下步骤:

  1. start-all.sh
  2. schematool -dbType mysql -initSchema
  3. 重置之后mysql数据库里数据没了,所以重新输入就行。
  4. mysql -uroot -p123123 -h127.0.0.1
  5. create database hdfsdb;
  6. use hdfsdb;
  7. create table student(stu_no int primary key, stu_name varchar(20), stu_age int);
  8. insert into student values(202001,"zhangsan",18);
  9. insert into student values(202002,"lisi",19);
  10. insert into student values(202003,"wangwu",20);
  11. exit;
  12. hive
  13. create table test2(stu_no int,stu_name string,stu_age int)
  14. row format delimited
  15. fields terminated by ",";
  16. exit;
  17. sqoop import --connect jdbc:mysql://127.0.0.1:3306/hdfsdb --username root --password 123123 --query 'select stu_no, stu_name,stu_age from student where stu_age>=20 and $CONDITIONS' --target-dir /user/root/hdfsdb6   --fields-terminated-by ',' -m 1 
  18. hive
  19. load data inpath '/user/root/hdfsdb6/part-m-00000' into table test2;
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/822583
推荐阅读
相关标签
  

闽ICP备14008679号