## 1、下载
```
http://sqoop.apache.org/
https://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.4.7/
```
对于sqoop-1.4.x.tar.gz软件包,从1.4.5开始以后版本安装包的lib下就已经没有了sqoop-1.4.x.jar啦,我们这里需要下载sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz。
```
[root@node1 ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/sqoop/1.4.7/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
[root@node1 ~]# tar -zxvf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
```
## 2、配置
### 进入目录
```
[root@node1 ~]# cd sqoop-1.4.7
[root@node1 sqoop-1.4.7]# ls
bin CHANGELOG.txt conf ivy lib NOTICE.txt README.txt sqoop-patch-review.py src
build.xml COMPILING.txt docs ivy.xml LICENSE.txt pom-old.xml sqoop-1.4.7.jar sqoop-test-1.4.7.jar testdata
[root@node1 sqoop-1.4.7]#
```
### 编辑配置文件
```
[root@node1 sqoop-1.4.7]# vi bin/configure-sqoop
```
* 这里应该要配置一些环境变量,比如zookeeper,hbase,现在暂时不用。
## 3、测试MySQL数据库
### 1复制驱动程序
```
[root@node1 mysql-connector-java-5.1.46]# cp mysql-connector-java-5.1.46-bin.jar /opt/sqoop-1.4.7/lib/
```
### 3.测试连接
```
[root@node1 sqoop-1.4.7]# bin/sqoop list-databases --connect jdbc:mysql://node3:3306/ --username root --password 123456
18/04/03 10:34:56 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
18/04/03 10:34:56 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
18/04/03 10:34:56 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
hive
mysql
performance_schema
test
webMagic
[root@node1 sqoop-1.4.7]#
```
### 3.从hdfs导入mysql
~~~
sqoop export --connect jdbc:mysql://192.168.2.101:3306/FlowDB --table WorkTable_hdfs --username root --password root --export-dir /user/jzyc/WorkTable/ --input-fields-terminated-by ','
~~~
* 这里是默认的导出模式,还有几种导出模式请查资料。
* --export-dir 是要导出的hdfs中的文件位置。
### 4.导出后中文乱码问题
[中文乱码问题](https://www.cnblogs.com/wang9911-00/p/12456530.html)