最近在Linux上裝了個MySQL數據庫,但是遠程鏈接MySQL時老是報出erro 2003: Can't connect to MySQL server on '211.87.***.***' (111),昨天查了好幾個小時才找到解決方案,以下:mysql
1.sudo gedit /etc/mysql.my.cnfsql
找到bind-address =127.0.0.1數據庫
修改成bind-address =0.0.0.0ui
2.sudo /etc/init.d/ mysql restartthis
在這種狀況下若是再嘗試遠程鏈接,則會報出ERROR 1130 (HY000): Host '211.87.***.***'is not allowed to connect to this MySQL server提示信息,不能遠程鏈接數據庫。rest
在MySQL host上按以下命令操做server
mysql -u root -ppassword //進入mysql控制檯ip
mysql>use mysql;it
mysql>update user set host = '%' where user = 'root'; //這個命令執行錯誤時可略過table
mysql>flush privileges;
mysql>select host, user from user; //檢查‘%’ 是否插入到數據庫中
mysql>quit
三、其它
mysqladmin -u root password 123 //改密碼 在/ety/my.cnf中加入skip-grant-tables //跳過mysql訪問控制