上一篇博客 同样的问题 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]#