查看完整版本: 解決 connect to this MySQL serverConnection closed 問題


toyota 2012-6-4 23:38

解決 connect to this MySQL serverConnection closed 問題

<div>最近在試特定IP連特定資料庫tables 時...遇到了一個問題...</div><div><br></div>not allowed to connect to this MySQL serverConnection closed by foreign host<br><br>有試著清掉 firewall 也不行,google了一下發現是MySQL預設是只接受localhost的連線<br><br>所以必須新增User並且指定可連線的IP,先用console登入, 然後用  grant 新增<br><br>一般新增語法<br>GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;<br><br>我是採用這個...console連進資料庫後...<br>Grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on dbname.* TO 'adj'@'111.222.211.%' identified by 'mypassword';<br><br>FLUSH PRIVILEGES;<br><br>再試一次,搞定!<br><br>P.S1: 上述的<span style="line-height: 20px; ">111.222.211.%</span>是表示只允許此段IP網段連入...如果要全部允許....只要將<span style="line-height: 20px; ">adj'@'111.222.211.%</span><span style="line-height: 20px; ">'&nbsp;</span><span style="line-height: 20px; ">&nbsp;改成&nbsp;</span><span style="line-height: 20px; ">adj'@'%</span><span style="line-height: 20px; ">'&nbsp; 就可以啦~~</span>
頁: [1]
查看完整版本: 解決 connect to this MySQL serverConnection closed 問題