Unable to import data from mysql to HDFS through Sqoop


6 Answer(s)


Hi Sarvani,

Please download and refer the document.
https://www.dropbox.com/s/ke886weetbk7cad/sqoop_meetup_kate_ting_110711.pdf?dl=0
Hope
or you can also refer this thread : http://stackoverflow.com/questions/12852695/apache-sqoop-communication-link-failure

Thanks for the quick reply.
I have already tried those solutions.
I am able to connect to mysql by this command(localhost)
mysql -h localhost -P 3306 -u root -p
But when I'm trying to do above import command, getting the above error.

and

I'm not able to connect to mysql with my hostname or ipaddress
mysql -h hostname -P 3306 -u root -p

My server hostname or ipaddress in which mysql and sqoop was installed is not able to connect to mysql.



Please refer the screenshot.


Please try this. sqoop import --connect "jdbc:mysql://localhost/sept27Batch" --username root --password 123456 -table author --target-dir /Sqoop/Sept27Batch/authTable -m 1

To solve any mysql related issue , follow the following advices:

Verify and test them with ping.
Refresh DNS or use IP address in JDBC URL instead.
Verify it based on my.cnf of MySQL DB.
Start the DB.
Verify if mysqld is started without the --skip-networking option.
Restart the DB and fix your code accordingly that it closes connections in finally.
Disable firewall and/or configure firewall/proxy to allow/forward the port.

hi Sarvani,

Check if you are able to connect to mysql with a valid username/password. Once it is confirmed use the below command to import (change the database/table names)

sqoop import \
--connect jdbc:mysql://localhost/employees \
--username root \
--password cloudera \
--table departments \
-m 4 \
--target-dir /user/cloudera/deps