遠程訪問mysql設置

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

java.sql.SQLException: Access denied for user 'root'@'xxx.xxx.xxx.xxx' at (數據庫名)mysql

表示該對象不是遠程對象,不能經過該對象遠程訪問數據sql

解決:數據庫

方案一:改表:服務器

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

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

方案二:受權法:.net

例如,你想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;server

不管使用哪一種方案,請重啓Mysql服務。對象

相關文章
相關標籤/搜索