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


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數據庫。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM