在Ubuntu9.10上使用sudo apt-get install mysql-server-5.0 安裝了mysql,
在外面訪問不了mysql,但是在Ubuntu上訪問是沒有問題的。
於是開始查找原因:
3306埠是不是沒有打開?
使用nestat命令查看3306埠狀態:
~# netstat -an | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

從結果可以看出3306埠只是在IP 127.0.0.1上監聽,所以拒絕了其他IP的訪問。
解決方法:修改/etc/mysql/my.cnf文件。打開檔,找到下面內容:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
把上面這一行注釋掉或者把127.0.0.1換成合適的IP,建議注釋掉。
重新啟動後,重新使用netstat檢測:
~# netstat -an | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
問題解決

arrow
arrow
    全站熱搜

    hweily 發表在 痞客邦 留言(0) 人氣()