Sqoop远程连接数据库
程序员文章站
2024-02-29 12:27:10
...
异常:java.sql.SQLException: null, message from server: “Host ‘***’ is not allowed to connect to this MySQL server”
java.sql.SQLException: null, message from server: "Host '***' is not allowed to connect to this MySQL server"
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1111)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2494)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
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:408)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:419)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
远程的机器不允许Sqoop访问他的数据库。要解决这个问题,就是要让远程机的数据库允许其他客户端访问;
操作步骤:
- 打开mysql控制台:
输入:
use mysql;
show tables;
use mysql;
show tables;
---------------------------------
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
-
更改user表
允许远程连接数据库
select host from user;
update user set host ='%' where user ='root';
如果报如下异常不用理会
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
- 刷新配置
flush privileges;
完成–
上一篇: java遍历字符串