sqoop mysql driver_Sqoop: Could not load mysql driver exception

I Installed Sqoop in my local machine. Following are the config information.

Bash.bashrc:

export HADOOP_HOME=/home/hduser/hadoop

export HBASE_HOME=/home/hduser/hbase

export HIVE_HOME=/home/hduser/hive

export HCAT_HOME=/home/hduser/hive/hcatalog

export SQOOP_HOME=/home/hduser/sqoop

export PATH=$PATH:$HIVE_HOME/bin

export PATH=$PATH:$HADOOP_HOME/bin

export PATH=$PATH:$HBASE_HOME/bin

export PATH=$PATH:$SQOOP_HOME/bin

export PATH=$PATH:$HCAT_HOME/bin

Hadoop:

Version: Hadoop 1.0.3

Hive:

Version: hive 0.11.0

Mysql Connector driver

version: mysql-connector-java-5.1.29

"The driver is copied to the lib folder of sqoop"

Sqoop :

version: sqoop 1.4.4

After making all the installation I create a table in mysql named practice_1, But when I run the load command to load data from mysql to hdfs the command throws an exception:

ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver

Coud anyone please guide me what can be the possible problem.

You need database driver in 'SQOOP' classpath check this

It has wonderful explanation about the 'SQOOP'

SQOOP has other options like

Ex: --driver com.microsoft.jdbc.sqlserver.SQLServerDriver -libjars=".*jar"

from here

You can use Sqoop with any other JDBC-compliant database. First, download the appropriate JDBC driver for the type of database you want to import, and install the .jar file in the $SQOOP_HOME/lib directory on your client machine. (This will be /usr/lib/sqoop/lib if you installed from an RPM or Debian package.) Each driver .jar file also has a specific driver class which defines the entry-point to the driver. For example, MySQL's Connector/J library has a driver class of com.mysql.jdbc.Driver. Refer to your database vendor-specific documentation to determine the main driver class. This class must be provided as an argument to Sqoop with --driver.

You may be interested in understanding the difference between connector and driver here is the article

selle

Another solution which avoids using a shared library is adding the driver jar to the classpath of sqoop by using HADOOP_CLASSPATH. I haven't got the -libjars option to work. This solution works also on a secure cluster using kerberos.

HADOOP_CLASSPATH=/use.case/lib/postgresql-9.2-1003-jdbc4.jar

sqoop export --connect jdbc:postgresql://db:5432/user \

--driver org.postgresql.Driver \

--connection-manager org.apache.sqoop.manager.GenericJdbcManager \

--username user \

-P \

--export-dir /user/hive/warehouse/db1/table1 \

--table table2

This one works at least with sqoop 1.4.3-cdh4.4.0

You need to add the MySql connector to /usr/lib/sqoop/lib.

MySQL JDBC Driver by default is not present in Sqoop distribution in order to ensure that the default distribution is fully Apache license compliant.

Hope this helps...!!!

If you have copied mysql driver to the sqoop lib folder. It will work for sure. Make sure you sqoop command is correct

/home/hduser/sqoop/bin/sqoop import --connect jdbc:mysql://localhost:3306/test --username root --password root -–table practice_1 -m 1

copy the 'mysql-connector-java-5.1.41-bin.jar' into sqoop/lib folder and execute sqoop import statements

It's a Oozie ShareLib problem. The script below works for my:

At Shell

sudo -u hdfs hadoop fs -chown cloudera:cloudera /user/oozie/share/lib/lib_20170719053712/sqoop

hdfs dfs -put /var/lib/sqoop/mysql-connector-java.jar /user/oozie/share/lib/lib_20170719053712/sqoop

sudo -u hdfs hadoop fs -chown oozie:oozie /user/oozie/share/lib/lib_20170719053712/sqoop

oozie admin -oozie http://localhost:11000/oozie -sharelibupdate

oozie admin -oozie http://localhost:11000/oozie -shareliblist sqoop

At Hue Sqoop Client

sqoop list-tables --connect jdbc:mysql://localhost/retail_db --username root --password cloudera

More detail at:

Chalpat

You need to grant priveleges to the tables as below:

grant all privileges on marksheet.* to 'root'@'192.168.168.1'

identified by 'root123';

flush privileges;

Here is sample command that I have successfully executed:

sqoop import --verbose --fields-terminated-by ',' --connect

jdbc:mysql://192.168.168.1/test --username root --password root123

--table student --hive-import --create-hive-table --hive-home /home/training/hive --warehouse-dir /user/hive/warehouse

--fields-terminated-by ',' --hive-table studentmysql

来源:https://stackoverflow.com/questions/22741183/sqoop-could-not-load-mysql-driver-exception

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个错误是由于Sqoop无法加载MySQL数据库驱动程序类com.mysql.jdbc.Driver导致的。可能是因为驱动程序JAR文件未正确配置或未在Sqoop的类路径中找到。您可以尝试检查以下内容: 1. 检查MySQL驱动程序JAR文件是否已正确配置到Sqoop的类路径中。 2. 确保MySQL驱动程序JAR文件已正确安装在Sqoop所在的机器上。 3. 检查MySQL驱动程序版本是否与Sqoop版本兼容。 4. 如果您使用的是CDH(Cloudera Distribution Hadoop),则可以尝试使用CDH提供的Sqoop版本和MySQL驱动程序版本。 希望这些提示可以帮助您解决问题。 ### 回答2: 该错误通常表示Sqoop无法加载MySQL JDBC驱动程序类com.mysql.jdbc.DriverSqoop需要这个驱动程序才能连接MySQL数据库,如果该类未找到,则Sqoop无法执行任何与MySQL相关的任务。 要解决此错误,有几个步骤可以尝试: 1. 检查MySQL JDBC驱动程序是否存在。请确保已将mysql-connector-java.jar文件放置在Sqoop类路径中。如果未在类路径中,则需要将其添加到类路径中。 2. 检查MySQL JDBC驱动程序的版本。Sqoop需要MySQL JDBC驱动程序的特定版本才能正常工作。请确保正在使用与Sqoop兼容的版本。 3. 检查sqoop-env.sh文件。如果使用的是Sqoop2,则需要在sqoop-env.sh文件中设置正确的数据库驱动程序,以便Sqoop2可以正确加载它。 4. 检查MySQL数据库是否在运行。如果MySQL数据库未运行,则无法使用Sqoop与其进行交互。 总之,如果遇到了这个错误,请先检查以上步骤,并确保所有设置都正确。这将确保Sqoop可以正确连接到MySQL数据库并执行所需的任务。 ### 回答3: 这个错误提示意味着在Sqoop运行时无法加载MySQL数据库的驱动程序。在Sqoop里,需要一个有效的数据库驱动程序来访问和操作数据库。这个错误通常出现在以下几种情况下: 1. 未正确安装MySQL JDBC驱动程序。 Sqoop需要用到MySQL数据库的JDBC驱动程序。如果没有正确地安装MySQL JDBC驱动程序,就会导致这个错误出现。解决此问题的方法是下载并正确安装MySQL JDBC驱动程序。 2. 没有将MySQL JDBC驱动程序添加到Sqoopclasspath中。 如果在Sqoopclasspath中没有将MySQL JDBC驱动程序添加到其中,就无法加载MySQL驱动程序。为了解决这个问题,需要将MySQL JDBC驱动程序添加到Sqoopclasspath中。可以使用export命令设置CLASSPATH变量来将JAR文件所在的目录添加到classpath中,或者在Sqoop命令中使用--driver选项指定MySQL驱动程序路径。 3. MySQL JDBC驱动程序版本不兼容。 如果MySQL JDBC驱动程序的版本不兼容,就会导致无法加载MySQL驱动程序。为了解决这个问题,需要确定MySQL驱动程序的版本是否与Sqoop兼容,并确保使用了兼容的驱动程序版本。 总之,这个错误提示表明出现了无法加载MySQL JDBC驱动程序的问题。要解决这个问题,需要确定MySQL JDBC驱动程序是否正确安装和添加到了Sqoopclasspath中,并确定驱动程序的版本是否与Sqoop兼容。只有这样,才能成功加载MySQL JDBC驱动程序并使用Sqoop访问和操作MySQL数据库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值