即使在connect参数中提供了远程服务器IP,Sqoop import也会尝试连接到本地mysql

时间:2018-04-29 09:33:59

标签: mysql hadoop hive sqoop

即使在connect参数中提供了远程服务器IP,Sqoop import也会尝试连接到本地mysql

我在下面尝试使用MySQL连接到远程MySQL服务器,它运行正常。我能够探索这些表格。

mysql -u anuser -h 1.133.23.58 -p

当尝试下面的代码时,它试图用" anuser"连接到本地MySQL实例。这是远程MySQL实例的用户。

sqoop-import -m 1 
--driver com.mysql.jdbc.Driver \\
--connect jdbc:mysql://1.133.23.58:3306/misp \ 
--username anuser \
--password password \
--query "select id, CURDATE() as ref_date, v, score, type, feed from AnDomains where \$CONDITIONS" \
--split-by id \
--hive-drop-import-delims \
--hive-import \
--hive-table testdb.andomains \
--target-dir andomains   

但我可以成功连接到sqlserver DB并将数据提取到hive表

错误MSG:

18/04/29 15:05:15 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6
18/04/29 15:05:15 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
18/04/29 15:05:15 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
18/04/29 15:05:15 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
18/04/29 15:05:16 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
18/04/29 15:05:16 INFO tool.CodeGenTool: Beginning code generation
18/04/29 15:05:16 ERROR manager.SqlManager: Error executing statement: java.sql.SQLException: Access denied for user 'anuser'@'120.0.0.1' (using password: YES)
java.sql.SQLException: Access denied for user 'ansuser'@'120.0.0.1' (using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)

1 个答案:

答案 0 :(得分:0)

您需要从请求连接的主机提供对用户的访问权限。在mysql命令提示符下执行以下命令:

GRANT ALL PRIVILEGES ON *.* TO 'ansuser'@'120.0.0.1' identified by 'passwordhere';