天天看點

mysql 拒絕通路的解決辦法

java.sql.SQLException: null,  message from server: "Host 'xxx' is not allowed to connect to this MySQL server":

表示該對象不是遠端對象,不能通過該對象遠端通路資料

解決:

方案一:改表:

use mysql ;select user,host,password from user;

update user set host = '%' where user='root';

方案二:授權法:

例如,你想myuser使用mypassword從任何主機連接配接到mysql伺服器的話。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允許使用者myuser從ip為192.168.1.3的主機連接配接到mysql伺服器,并使用mypassword作為密碼

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

總結:MySQL預設隻支援本機通路,若要實作網絡通路,則要把源計算機的IP更新到user表中。