参考 https://www.cnblogs.com/playforever/p/9103912.html
下载
wget http://mirror.bit.edu.cn/apache/sqoop/1.4.7/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz
解压
将hive的mysql-connector-java-8.0.23.jar拷贝到sqoop的lib目录下
下载commons-lang-2.6-bin.zip
wget http://mirrors.tuna.tsinghua.edu.cn/apache//commons/lang/binaries/commons-lang-2.6-bin.zip
解压并将commons-lang-2.6.jar复制到sqoop的lib目录
cp commons-lang-2.6.jar /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/lib/
配置环境变量/etc/profile
export SQOOP_HOME=/opt/module/sqoop-1.4.7.bin__hadoop-2.6.0
export PATH=$PATH:$SQOOP_HOME/bin
sqoop输入密码问题解决
修改 sqoop-site.xml,使下面配置有效
<property>
<name>sqoop.metastore.client.record.password</name>
<value>true</value>
<description>If true, allow saved passwords in the metastore.
</description>
</property>
测试
[datalink@slave3 conf]$ sqoop eval --connect jdbc:mysql://slave4:3306/testdb --username hive -password Tian@1949 --query ‘select count(1) from t_role‘
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
2021-02-07 13:46:31,579 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2021-02-07 13:46:31,673 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2021-02-07 13:46:31,786 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver‘. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
-----------------------
| count(1) |
-----------------------
| 2 |
-----------------------
[datalink@slave3 conf]$ sqoop list-databases --connect jdbc:mysql://slave4:3306/testdb --username hive -password Tian@1949
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /opt/module/sqoop-1.4.7.bin__hadoop-2.6.0/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
2021-02-07 13:45:57,408 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
2021-02-07 13:45:57,507 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
2021-02-07 13:45:57,626 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver‘. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
mysql
information_schema
performance_schema
sys
hive
testdb
原文:https://www.cnblogs.com/playforever/p/14384775.html