从sqoop远程访问mysql

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

我可以通过连接到远程服务器上的sql示例

mysql -h ServerIP -u root -p dbNamE

但是当我尝试使用命令通过sqoop连接时:

sqoop list-tables --driver com.mysql.jdbc.Driver --connect jdbc:mysql://IP:port/dbName --username userName --password password

它抛出以下错误:

16/05/06 16:46:46 ERROR manager.SqlManager: Error reading database metadata: java.sql.SQLException: Access denied for user 'root'@'IP' (using password: YES)
java.sql.SQLException: Access denied for user 'root'@'IP' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:885)
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
at org.apache.sqoop.manager.SqlManager.listTables(SqlManager.java:520)
at org.apache.sqoop.tool.ListTablesTool.run(ListTablesTool.java:49)
at org.apache.sqoop.Sqoop.run(Sqoop.java:148)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:184)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:226)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:235)
at org.apache.sqoop.Sqoop.main(Sqoop.java:244)
Could not retrieve tables list from server
16/05/06 16:46:46 ERROR tool.ListTablesTool: manager.listTables() returned null

我能澄清一下吗?
我该怎么解决这个问题?

p1tboqfb

p1tboqfb1#

验证您的连接用户名是否正确,例如,如果您可以使用“-u root”直接连接到mysql,那么在使用sqoop连接时,您应该使用相同的用户名值。
否则,当我没有在hive-site.xml文件中配置用户名和密码时,会收到类似的消息:它会尝试使用默认密码(该文件可以在您的hive安装文件夹/conf中找到)。
如果是这种情况,则只需在该文件中配置这些属性:

<property>
      <name>javax.jdo.option.ConnectionUserName</name>
      <value>userName</value>
      <description>user name for connecting to mysql server</description>
   </property>

   <property>
      <name>javax.jdo.option.ConnectionPassword</name>
      <value>password</value>
      <description>password for connecting to mysql server</description>
   </property>

相关问题