1.sudo gedit /etc/mysql.my.cnf
找到bind-address =127.0.0.1
修改為bind-address =0.0.0.0
2.sudo /etc/init.d/ mysql restart
在這種情況下如果再嘗試遠(yuǎn)程連接襟企,則會(huì)報(bào)出ERROR 1130 (HY000): Host '211.87..'is not allowed to connect to this MySQL server提示信息,不能遠(yuǎn)程連接數(shù)據(jù)庫(kù)嗤军。
在MySQL host上按如下命令操作
mysql -u root -ppassword //進(jìn)入mysql控制臺(tái)
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'; //這個(gè)命令執(zhí)行錯(cuò)誤時(shí)可略過(guò)
mysql>flush privileges;
mysql>select host, user from user; //檢查‘%’ 是否插入到數(shù)據(jù)庫(kù)中
mysql>quit