在mysql遠端連線時出現error 2003錯誤的很多種,下面我來給大家介紹兩種解決此問題的方法,有需要的同學可參考。
問題****
error 2003 (hy000): can't connect to mysql server on '192.168.0.19' (111)
error 2003 (hy000): can't connect to mysql server on '192.168.0.19' (111) 這個 原因就是mysql資料庫的預設配置檔案my.cnf(linux下)中的bind-address預設為127.0.0.1,所以就算你建立了可以 remote訪問的使用者,你也不能使用mysql -h命令進行訪問,若訪問就會出現上出問題,因為此時mysql只接受localhost,所以需要把bind-address遮蔽掉。
my.cnf一般在/etc/mysql下面,如果不在使用locate my.cnf查詢,修改前的my.cnf配置檔案為:
修改前的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
## 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
我們需要做的就是遮蔽這個bind-address**,遮蔽後**為:
遮蔽後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
## 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
現在你就可以用mysql -h命令進行你想做的操作了,如登入系統:
登陸資料庫**
mysql -h 192.168.0.19 -u root -p
如果上面還不能解決可能是防火強的問題了
1.mysql 錯誤 error 2003 (hy000): can't connect to mysql server on 'localhost'
解決辦法:關閉防火牆,安陽電腦網,linux下命令
[root@etl01 bin]# chkconfig --list | grep -i iptables ====check fire wall
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@etl01 bin]# /sbin/service iptables stop ====stop fire wall
flushing firewall rules: [ ok ]
setting chains to policy accept: nat filter [ ok ]
unloading iptables modules: [ ok ]
2.報錯:1130-host ... is not allowed to connect to this mysql server
解決辦法:
授權形式
比如賬戶為root,密碼為root
use mysql;
用root賬戶從任何主機上訪問mysql資料庫了
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
如果你想允許使用者zz從ip為192.168.1.3的主機連線到mysql伺服器,並使用123456作為密碼
grant all privileges on *.* to 'root'@'192.168.1.3' identified by '123456' with grant option;
遠端連線MySQL報錯ERROR 2003解決辦法
問題 error 2003 hy000 can t connect to mysql server on 192.168.0.19 111 error 2003 hy000 can t connect to mysql server on 192.168.0.19 111 這個 原因就是mysql資...
遠端連線報錯
遠端登入卻報錯host is not allowed to connect to this mysql server 解決方法 在裝有mysql的機器上登入mysql mysql u root p密碼 執行use mysql 執行update user set host where user roo...
CentOS中MySQL遠端連線報錯巔峰解決方法
centos中mysql遠端連線報錯巔峰解決方法 執行環境,系統版本 centos 7,資料庫版本 5.6.xx。問題用工具遠端登入連線基於centos 7伺服器上的mysql,報錯資訊如下 解決方案 檢查預設埠 3306 是否開放,若埠未開放則進行如下操作 方式1 iptables centos ...