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;