Sree Eedupuganti
Sree Eedupuganti

Reputation: 440

Unable to import the table from Mysql using Sqoop

I have 5 records in employee table in demo_poc database in MySQL in

192.168.1.126 [Machine-1].

I want to import the data into hive in

192.168.1.129 [Machine-2] using Sqoop.

I Installed sqoop 1.4.6 on Machine-2.

I tried like this,

sqoop import --connect jdbc:mysql://192.168.1.126:3306/demo_poc 
--username root --password root --table employee -m 10
--hive-import --hive-table demo_poc.address

Here is the error I received,

16/04/11 16:28:20 INFO tool.CodeGenTool: Beginning code generation 
16/04/11 16:28:21 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 
16/04/11 16:28:21 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter

Any suggestions. Thanks.

Upvotes: 1

Views: 544

Answers (5)

Sanjeev Budni
Sanjeev Budni

Reputation: 1

  1. you have to mention the --target-dir

for example : sqoop import --connect "mysql://192.168.1.126:3306/demo_poc "

--username root --password "root"

--query "select column_name from table_name where \$CONDITIONS"

--fields-terminated-by ',' --target-dir /user/.... -m 1 --delete-target-dir --as-parquetfile

Upvotes: 0

Sree Eedupuganti
Sree Eedupuganti

Reputation: 440

sqoop-import --connect jdbc:mysql://192.168.1.126:3306/demo_poc --username root --P --table employee -m 1 --hive-import --hive-table demo_poc.employee

Upvotes: 1

Sravan Kumar
Sravan Kumar

Reputation: 1

The IP addresses which you provided looks like in the same network. If these two machines are in the network then the ping command will able to work. After we enter the ping 'I.P of MYSQL' then communication will etsablishes.

MYSQL>grant all privileges on . to ''@'192.168.1.129' MYSQL>grant all privileges on . to '%'@'192.168.1.129' above two commands executed on MYSQL machine by admin.

Upvotes: 0

Suvarna Pattayil
Suvarna Pattayil

Reputation: 5239

This error occurs due to many reasons. You can start with this,

  • This error can occur when you have erroneous MySQL credentials too. Connect to MySQL on Machine 2 using the credentials used in Sqoop from the CLI on Machine 2. Check for the exact database, commands etc. If you are not able to do that, it can be host related permission issue for the MySQL user you are using in Sqoop command.

Upvotes: 0

Dev
Dev

Reputation: 13753

Seems like you are not able to make connection with MySQL.

Check two things.

  1. Is machine on which MySQL is running accessible?

    try ping 192.168.1.126 command from sqoop machine.

  2. Check Mysql port.

This question will help you in that.

Upvotes: 0

Related Questions