Can't connect to MySQL server on 'IP' (13)

Source: Internet
Author: User

I tried to connect to a remote MySQL Server (192.168.1.197) from a server with IP 192.168.1.193.
My php connect:
$ Host = "192.168.1.197 ";
$ User = "root ";
$ Pass = "rootpassword ";
$ Database = "sample1 ";
# $ Con = @ mysql_connect ("$ host", "$ user", "$ pass") or die ('error connecting to mysql ');
$ Con = mysql_connect ("$ host", "username", "password") or die (mysql_error ());
$ Db = "$ Database"; @ mysql_select_db ($ db, $ con );

When I run this in the web, I'm getting the (13) error. I 've searched the web but cocould not find any concrete answer.

If I type this in the command prompt:
[Root @ localhost include] # mysql-u root-H 192.168.1.197-P
Enter password:
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 71
Server version: 5.0.51a Source Distribution

Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.

Mysql>

I was able to connect ..

Can someone help me on this one?

I even created a user rights for root (both 193 & 197)
User host password global privileges Grant
Root 192.168.1.193 Yes All privileges Yes
Root 192.168.1.197 Yes All privileges Yes

 

Solution 1: setsebool-P httpd_can_network_connect_db = 1

Solution 2: Modify/etc/SELinux/config SELinux = enforcing to SELinux = disabled

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.