Linux下MySQL Error 1130 不能遠程訪問mysql
內容簡介:遠程鏈接MySQL時老是報出erro 2003: Can't connect to MySQL server on '211.87.***.***' (111),昨天查了好幾個小時才找到解決方案,以下:……sql
最近作Linux項目用到MySQL數據庫,但是遠程鏈接MySQL時老是報出erro 2003: Can't connect to MySQL server on '211.87.***.***' (111),昨天查了好幾個小時才找到解決方案,以下:數據庫
1.sudo gedit /etc/mysql.my.cnfui
找到bind-address =127.0.0.1this
修改成bind-address =0.0.0.0rest
2.sudo /etc/init.d/ mysql restartserver
在這種狀況下若是再嘗試遠程鏈接,則會報出ERROR 1130 (HY000): Host '211.87.***.***'is not allowed to connect to this MySQL server提示信息,不能遠程鏈接數據庫。it
在MySQL host上按以下命令操做date
mysql -u root -p //進入mysql控制檯select
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'; //這個命令執行錯誤時可略過
mysql>flush privileges;
mysql>select host, user from user; //檢查‘%’ 是否插入到數據庫中
mysql>quit