Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

sqoop import error

Solved Go to solution

sqoop import error

Explorer

I am trying to import a table named 'widgets' in the data base 'Testdb' with the command below:

$sqoop import --connect jdbc:mysql://hadoop/Testdb --table widgets -m 4 -username root -P

I get the error "Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver"

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: sqoop import error

Super Mentor

@Aymen Rahal

If you do not have the mysql driver in your host then please install it as following:

# yum install mysql-connector-java*
# cp -f /usr/share/java/mysql-connector-java.jar  /usr/hdp/current/sqoop-client/lib/

.

If you do not want to use "yum" to install mysql-connector-java then you can also download the tar archive of the connector from the following site and then put the extracted JAR (mysql-connector-java*.jar) inside the "usr/hdp/current/sqoop-client/lib/"

https://dev.mysql.com/downloads/connector/j/

.

View solution in original post

14 REPLIES 14
Highlighted

Re: sqoop import error

Mentor

@Aymen Rahal

Did you copy the JDBC driver (mysql-connector-java*) to the $SQOOP_HOME/lib directory of your Sqoop installation.?

Then re-run the command

Highlighted

Re: sqoop import error

Explorer

$ls -ltr /usr/share/java/mysql-connector-java-5.1.17.jar

ls: cannot access '/usr/share/java/mysql-connector-java-5.1.17.jar': No such file or directory

Highlighted

Re: sqoop import error

Super Mentor

@Aymen Rahal

You will need to download the mysql-connector-java (MySQL JDBC driver) and then put it to the following location:

 # cp -f /usr/share/java/mysql-connector-java.jar  /usr/hdp/current/sqoop-client/lib/


The you can run the Sqoop command something like following:

 # su -l sqoop -c "sqoop import --connect jdbc:mysql://hadoop/Testdb --table widgets -m 4 --username root --password CHANGEME --driver com.mysql.jdbc.Driver"

.

Highlighted

Re: sqoop import error

Super Mentor
Highlighted

Re: sqoop import error

Explorer

$ cp -f /usr/share/java/mysql-connector-java.jar /usr/hdp/current/sqoop-client/lib/

cp: '/usr/share/java/mysql-connector-java.jar' and '/usr/hdp/current/sqoop-client/lib/mysql-connector-java.jar' are the same file

Highlighted

Re: sqoop import error

Super Mentor

@Aymen Rahal

Do you see the following symlink exist with the following user permission:

# ls -l /usr/hdp/current/sqoop-client/lib/mysql-connector-java.jar
lrwxrwxrwx. 1 root root 40 Jun  9  2017 /usr/hdp/current/sqoop-client/lib/mysql-connector-java.jar -> /usr/share/java/mysql-connector-java.ja

.

Also do you see the following command shows the class found?

# jar -tvf /usr/share/java/mysql-connector-java.jar | grep 'com.mysql.jdbc.Driver' 
   919 Tue Jan 01 00:00:00 UTC 1980 com/mysql/jdbc/Driver.class

.

Highlighted

Re: sqoop import error

Super Mentor

@Aymen Rahal

If you do not have the mysql driver in your host then please install it as following:

# yum install mysql-connector-java*
# cp -f /usr/share/java/mysql-connector-java.jar  /usr/hdp/current/sqoop-client/lib/

.

If you do not want to use "yum" to install mysql-connector-java then you can also download the tar archive of the connector from the following site and then put the extracted JAR (mysql-connector-java*.jar) inside the "usr/hdp/current/sqoop-client/lib/"

https://dev.mysql.com/downloads/connector/j/

.

View solution in original post

Highlighted

Re: sqoop import error

Explorer

#su -l sqoop -c "sqoop import --connect jdbc:mysql://hadoop/Testdb --table widgets -m 4 --username root --password CHANGEME --driver com.mysql.jdbc.Driver"

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Highlighted

Re: sqoop import error

Super Mentor

Now the error says that it is not able to communicate with MySQL server.

So please check if your mysql server is running file and listening to "hadoop:3306" port

# netstat -tnlpa | grep 3306
# hostname -f
# ps -ef | grep mysql

.

Also please check if there is any issue/error logged in mysql log.

.

Don't have an account?
Coming from Hortonworks? Activate your account here