export sqoop命令出错

u3r8eeie  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(450)

我用的是导出命令 sqoop 从导出时遇到此错误 hdfsMySQL 命令是:

sqoop export 
--connect jdbc:mysql://localhost/property 
--username root 
--password root 
--table xyz 
--m 1 
--export-dir abc.csv

错误是:

16/08/30 23:11:33 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
16/08/30 23:11:34 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
16/08/30 23:11:34 INFO tool.CodeGenTool: Beginning code generation
16/08/30 23:11:34 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver
java.lang.RuntimeException: Could not load db driver class: com.mysql.jdbc.Driver
    at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:848)
    at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
    at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:736)
    at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:759)
    at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:269)
    at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240)
    at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:226)
    at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295)
    at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1773)
    at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1578)
    at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
    at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:64)
    at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:100)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
p8h8hvxi

p8h8hvxi1#

添加 mysql-connector.jar$SQOOP_HOME/lib .
根据sqoop文件,
您可以将sqoop与任何其他jdbc兼容的数据库一起使用。首先,为要导入的数据库类型下载适当的jdbc驱动程序,并安装 .jar 文件在 $SQOOP_HOME/lib 客户端计算机上的目录
也,
每个驱动程序 .jar 文件还有一个特定的驱动程序类,它定义了驱动程序的入口点。例如,mysql的connector/j库有一个驱动程序类 com.mysql.jdbc.Driver . 请参阅特定于数据库供应商的文档以确定主驱动程序类。此类必须作为sqoop的参数提供 --driver .
所以,加上 --driver com.mysql.jdbc.Driver 听你指挥。

相关问题