1. 程式人生 > >Mysql報錯 message from server: "Host '61.148.245.96' is not allowed to connect to this MySQL server

Mysql報錯 message from server: "Host '61.148.245.96' is not allowed to connect to this MySQL server

 

原因是:遠端伺服器不允許你的java程式訪問它的資料庫。所以,我們要對遠端伺服器進行設定,使它允許你進行連線。

步驟:一、開啟mysql控制檯,輸入:use mysql;

二、輸入:show tables;

三、輸入:select host from user;

 

四、輸入:update user set host ='%' where user ='root';

五、開啟計算機的服務介面,重新啟動mysql服務,遠端伺服器就允許程式連線資料庫了。

或者修改完成後,執行:flush privileges;  

 

 

 

 將修改內容生效,再次配置時,用IP地址或者localhost 就都能正常連線到MySQL資料庫了。