【解決】ERROR 2003 (HY000): Can't connect to MySQL server on "host" (113)
連線遠端MySQL時報錯:
ERROR 2003 (HY000): Can’t connect to MySQL server ‘ip’ (113)
首先確認建立MySQL帳號是否正確
# mysql -u root -p
Enter password:
mysql> GRANT ALL ON *.* to USERNAME@'%' IDENTIFIED BY 'PASSWORD';
mysql> FLUSH PRIVILEGES;
mysql> select user, host from mysql.user; (查詢user列表)
mysql> quit
導致此錯誤的原因為伺服器端防火牆未開放MySQL程式使用的埠,預設為3306,開放埠即可
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
儲存設定並重啟防火牆
service iptables save
service iptables restart
留言
張貼留言