遠端連線CentOS的MySQL報錯:Can't connect to MySQL server on 'XXX' (13),centosmysql

來源:互聯網
上載者:User

遠端連線CentOS的MySQL報錯:Can't connect to MySQL server on 'XXX' (13),centosmysql
環境:

系統版本: CentOS release 6.5 (Final)

資料庫版本: 5.1.73


問題描述:

使用用戶端遠程登入串連基於CentOS 6.5伺服器上的Mysql,報錯:Can't connect to MySQL server on 'XXX' (13)


解決方案:

通常情況下,可以進行如下設定
1. 進入MySQL的控制台
# mysql -u root -p

2. 在MySQL的控制台中輸入如下命令
mysql> grant all privileges on *.* to 'root'@'your-host-ip' identified by 'your-mysql-password' with grant option;
mysql> flush privileges;
mysql> exit

3. 重啟Mysql
# /etc/init.d/mysqld restart
至此,不出意外已經完成修改,並驗證通過。

但是如果此時還是出現Can't connect to MySQL server on 'XXX' (13)的錯誤提示,可以嘗試如下方法:

1. 查看httpd_can_network_connect的值是否為off(例如:httpd_can_network_connect --> off)
# getsebool -a | grep httpd

2. 修改httpd_can_network_connect的值為on
# setsebool httpd_can_network_connect 1

3. 重新驗證httpd_can_network_connect
# getsebool -a | grep httpd

4. 重啟http
# /etc/init.d/httpd restart

5. 進入用戶端重啟登入驗證
此時錯誤資訊變為:Access denied for user 'root'@'your-host-ip'(usring password:YES)

6. 進入Mysql控制台重新GRANT(如上)

相關文章

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.