遠端連線MySQL報錯ERROR 2003解決辦法

來源:互聯網
上載者:User


問題代碼代碼

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;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.