面对sqoop中以下命令的问题

时间:2014-06-21 15:51:01

标签: mysql hadoop sqoop

我已经在sqoop / lib文件夹中复制了jar文件,而我在sqoop中使用的命令是:

  

bin / sqoop import --connect jdbc:mysql:// localhost:3306 / sqoop --username root --password admin --table cities

错误讯息:

14/06/21 08:44:44错误sqoop.Sqoop:运行异常Sqoop:java.lang.RuntimeException:无法加载db驱动程序类:com.mysql.jdbc.Driver java.lang.RuntimeException:无法加载db驱动程序类:com.mysql.jdbc.Driver     在org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:772)     at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)     在org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:660)     在org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:683)     在org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240)     在org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:223)     at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:347)     at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1277)     在org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1089)     在org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)     在org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:396)     在org.apache.sqoop.tool.ImportTool.run(ImportTool.java:502)     在org.apache.sqoop.Sqoop.run(Sqoop.java:145)     在org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)     在org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)     在org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)     在org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)     在org.apache.sqoop.Sqoop.main(Sqoop.java:238)

3 个答案:

答案 0 :(得分:0)

您需要将mysql-connector jar文件添加到sqoop / lib文件夹以访问mysql数据库。 然后执行sqoop命令。

下载链接:http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6

答案 1 :(得分:0)

从此link下载mysql-connector jar。 将mysql-connector-java-5.1.46.jar文件解压缩并复制到$ SQOOP_HOME / lib /目录。 如果sqoop与hdfs一起使用,则将相同的jar复制到hdfs中存在的lib。

答案 2 :(得分:0)

尝试添加此选项

--driver com.mysql.jdbc.Driver

还请确保您已运行以下命令

% mysql -u root -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON sqoop.* TO ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye