惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
F
Fortinet All Blogs
D
Docker
博客园 - 司徒正美
腾讯CDC
Recent Announcements
Recent Announcements
The Cloudflare Blog
B
Blog RSS Feed
GbyAI
GbyAI
T
Tailwind CSS Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志

博客园 - Winner.Net(2007)

centos 端口开放及关闭 CentOS 6.0 系统 LAMP(Apache+MySQL+PHP)安装步骤 linux 开启 mount PHP与MYSQL事务处理 型B2C电子商务网站组织架构分析 转 PHP _construct _destory _call _get _set等 - Winner.Net(2007) eew CSS+js 实现mouse移动单元格上全部显示 web2.0网站的性能优化方法 (转) Web应用性能优化黄金法则——转 js编码处理(转) 服务器推技术 网页标签解析 转http状态码 登陆抓取数据 - Winner.Net(2007) - 博客园 观察者+js 模式 - Winner.Net(2007) - 博客园 JS倒计时 - Winner.Net(2007) - 博客园 sql得到时间 EXT 列头合并的例子 - Winner.Net(2007) - 博客园
Can't connect to MySQL server on 'ip' (13)
Winner.Net(2007) · 2011-11-17 · via 博客园 - Winner.Net(2007)

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 search the web but could 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

解决方法1、:setsebool -P httpd_can_network_connect_db=1

解决方法2、:修改/etc/selinux/config SELINUX=enforcing 为 SELINUX=disabled