MySQL報錯"Host ' is not allowed to connect to this MySQL server"


Android連接數據庫,MySQL報錯:W/System.err: java.sql.SQLException: null,  message from server: "Host 'WIN-BFHI27MPO93' is not allowed to connect to this MySQL server"

原因是:遠程服務器不允許你的java程序訪問它的數據庫。

解決步驟:

1、打開mysql控制台,輸入:use mysql;

2、輸入:show tables;

3、輸入:select host from user;

    user為root,host為localhost的話,說明mysql只允許本機連接

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

5、執行刷新權限,輸入:flush privileges;


免責聲明!

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



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