標籤:分配 at命令 database bin sql 還需 network 修改 ide
1. 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 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
2. 問題解決了嗎?
現在使用下面命令測試:
~# mysql -h 10.1.1.2 -u root -pEnter password:ERROR 1130 (00000): Host ‘B0324-Desktop.local‘ is not allowed to connect to this MySQL server
結果出乎意料,還是不行。
解決方案:原來還需要把使用者權限分配各遠端使用者。
登入到mysql伺服器,使用grant命令分配許可權
mysql> grant all on database_name.* to [email protected]‘%‘ identified by ‘user_password‘;
其中database_name、user_name和user_password根據實際情況設定。
完成後使用mysql命令串連,提示成功,為了確保正確可以再遠程登陸測試一下。
轉自:http://blog.csdn.net/mydeman/article/details/3847695
Ubuntu上的MySQL可以遠端存取