Board logo

標題: [介紹] 解決 connect to this MySQL serverConnection closed 問題 [打印本頁]

作者: toyota    時間: 2012-6-4 23:38     標題: 解決 connect to this MySQL serverConnection closed 問題

最近在試特定IP連特定資料庫tables 時...遇到了一個問題...

not allowed to connect to this MySQL serverConnection closed by foreign host

有試著清掉 firewall 也不行,google了一下發現是MySQL預設是只接受localhost的連線

所以必須新增User並且指定可連線的IP,先用console登入, 然後用 grant 新增

一般新增語法
GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

我是採用這個...console連進資料庫後...
Grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on dbname.* TO 'adj'@'111.222.211.%' identified by 'mypassword';

FLUSH PRIVILEGES;

再試一次,搞定!

P.S1: 上述的111.222.211.%是表示只允許此段IP網段連入...如果要全部允許....只要將adj'@'111.222.211.% 改成 adj'@'%'  就可以啦~~




歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) Powered by Discuz! 6.0.0