The spark program remotely connects to the mysql database and reports an error

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"


Reason for error: mysql server does not allow remote connection

After searching for information, the solution is as follows:

Log in to the mysql database:

mysql -uroot -p


carried out

use mysql;

show tables;



View: select host from user;


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



Then restart the mysql service and resubmit the spark program to successfully write the data to mysql

Guess you like

Origin blog.csdn.net/u013963379/article/details/81058963