sqoop从mysql导入数据到hive,密码比较复杂时要用英文单引号‘‘

上一篇博客 同样的问题 https://blog.csdn.net/weixin_41956627/article/details/108238467

今天发现mysql密码比较复杂,有个 & 符合,要用单引号括起来才行

1.不处理的时候

密码被拆了,两个报错如下:1、未找到命令,2、把mysql指到本地地址了

其中192.168.x.x是远程mysql的地址,172.xxx是sqoop本地地址

在这里插入图片描述

[root@hd01 lib]# sqoop list-databases --connect jdbc:mysql://192.168xxx.xxxx/?useSSL=false --username lqer --password c******9&Es%5$C#oq
[1] 76190
-bash: Es%5#oq: 未找到命令
[root@hd01 lib]# SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
20/08/27 11:01:57 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7-cdh6.2.1
20/08/27 11:01:57 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
20/08/27 11:01:57 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
20/08/27 11:01:57 ERROR manager.CatalogQueryManager: Failed to list databases
java.sql.SQLException: Access denied for user ‘lqer’@‘172.20.xxx.xxx’ (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

2.用双引号包围密码

还是把 mysql指到本地地址了
在这里插入图片描述

3.用单引号包围密码

执行成功
在这里插入图片描述

4.用文件的方式取密码还是没成功
5.密码别名模式 --password-alias

参考:
https://www.jianshu.com/p/0331a3bce6e0
https://blog.csdn.net/weixin_34419321/article/details/94734365

# sudo -u hdfs hadoop credential create mydy123456 -provider jceks://hdfs/user/password/mydy
# sudo -u hdfs hdfs dfs -chmod 555 /user/password/mydy

在这里插入图片描述

不改权限的话还是会读取失败

[root@hd01 lib]# sqoop list-databases -Dhadoop.security.credential.provider.path=jceks://hdfs/user/password/mydy --password-alias mydy123456 --connect jdbc:mysql://192.168.x.x:xxx/?useSSL=false --username lxxx
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
20/08/27 14:06:16 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7-cdh6.2.1
Error resolving password from the credential providers
[root@hd01 lib]#

修改权限后执行读取密码成功

[root@hd01 lib]# sudo -u hdfs hdfs dfs -chmod 555 /user/password/mydy
[root@hd01 lib]# sqoop list-databases -Dhadoop.security.credential.provider.path=jceks://hdfs/user/password/mydy --password-alias mydy123456 --connect jdbc:mysql://192.168.x.x:xxxx/?useSSL=false --username lxxx
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.4951328/jars/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
20/08/27 14:08:26 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7-cdh6.2.1
20/08/27 14:08:27 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
information_schema
mydy
[root@hd01 lib]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值