0

Sqoop import always tries to connect to local mysql even when remote server IP is provided in connect parameter

I tried below connect using MySQL to remote MySQL server and it is working fine. I am able to explore the tables.

mysql -u anuser -h 1.133.23.58 -p

when tried the below code it is trying to connect to local MySQL instance with the "anuser" which is the user for remote MySQL instance.

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   

but I can connect to sqlserver DB successfully and pull data to hive tables

Error 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 Answers1

0

You need provide access to the user from host where it is requesting to connect .Execute the below in your mysql command prompt :

GRANT ALL PRIVILEGES ON *.* TO 'ansuser'@'120.0.0.1' identified by 'passwordhere';
Taha Naqvi
  • 1,756
  • 14
  • 24