Ubuntu上的MySQL能夠遠程訪問

1. 3306端口是否是沒有打開?mysql

使用nestat命令查看3306端口狀態:sql

~# netstat -an | grep 3306

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN服務器

從結果能夠看出3306端口只是在IP 127.0.0.1上監聽,因此拒絕了其餘IP的訪問。less

解決方法:修改/etc/mysql/my.cnf文件。打開文件,找到下面內容:tcp

# 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,建議註釋掉。ide

從新啓動後,從新使用netstat檢測:測試

~# netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

2. 問題解決了嗎?this

如今使用下面命令測試spa

 ~# mysql -h 10.1.1.2 -u root -p
Enter password:
ERROR 1130 (00000): Host 'B0324-Desktop.local' is not allowed to connect to this MySQL server

結果出乎意料,仍是不行。.net

解決方法:原來還須要把用戶權限分配各遠程用戶。

登陸到mysql服務器,使用grant命令分配權限

mysql> grant all on database_name.* to user_name@'%' identified by 'user_password';

其中database_name、user_name和user_password根據實際狀況設置。

完成後使用mysql命令鏈接,提示成功,爲了確保正確能夠再遠程登錄測試一下。

轉自:http://blog.csdn.net/mydeman/article/details/3847695

相關文章
相關標籤/搜索