使用Sqoop1.4.4将MySQL数据库表中数据导入到HDFS中

本文介绍了如何使用Sqoop1.4.4将MySQL数据库的数据导入到HDFS中,包括必备参数如连接字符串、用户名、密码和表名,并详细解释了--columns和--where参数的用途,以及数据导入后的默认路径。示例展示了如何选择部分列和过滤条件进行数据导入。
摘要由CSDN通过智能技术生成

问题导读:

        1、--connect参数作用?

        2、使用哪个参数从控制台读取数据库访问密码?

        3、Sqoop将关系型数据库表中数据导入HDFS基本参数要求及命令?

        4、数据默认导入HDFS文件系统中的路径?

        5、--columns参数的作用?

        6、--where参数的作用?

一、部分关键参数介绍

参数介绍
--connect <jdbc-uri>	             指定关系型数据库JDBC连接字符串
--connection-manager <class-name>    指定数据库使用的管理类
--driver <class-name>	             手动指定要使用JDBC驱动程序类
--hadoop-mapred-home <dir>	     重写覆盖$HADOOP_MAPRED_HOME
--help	 			     使用提示帮助提示
--password-file	                     设置包含身份验证密码的路径文件
-P	                             从控制台读取数据库访问密码
--password <password>	             设置数据库身份验证密码
--username <username>	             设置数据库访问用户
--verbose	                     打印更多程序执行流程信息
--connection-param-file <filename>   用于提供连接参数的可选的属性文件
二、要导出的MySQL数据库

[hadoopUser@secondmgt ~]$ mysql -uhive -phive spice
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 419
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from users;
+----+----------+----------+-----+---------+------------+-------+------+
| id | username | password | sex | content | datetime   | vm_id | isad |
+----+----------+----------+-----+---------+------------+-------+------+
| 56 | hua      | hanyun   | 男  | 开通    | 2013-12-02 |     0 |    1 |
| 58 | feng     | 123456   | 男  | 开通    | 2013-11-22 |     0 |    0 |
| 59 | test     | 123456   | 男  | 开通    | 2014-03-05 |    58 |    0 |
| 60 | user1    | 123456   | 男  | 开通    | 2014-06-26 |    66 |    0 |
| 61 | user2    | 123      | 男  | 开通    | 2013-12-13 |    56 |    0 |
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值