spark程序远程连接mysql数据库报错

Exception in thread "main" java.sql.SQLException: null,  message from server: "Host '192.168.1.121' is not allowed to connect to this MySQL server"


报错原因:mysql服务器不允许远程连接

经查找资料,解决方式如下:

登录mysql数据库:

mysql -uroot -p


执行

use mysql;

show tables;



查看:select host from user;


修改:update user set host = '%' where user = 'root';



然后重启mysql服务,重新提交spark程序成功将数据写入mysql

猜你喜欢

转载自blog.csdn.net/u013963379/article/details/81058963
今日推荐