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

推荐订阅源

雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
D
Docker
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
U
Unit 42

博客园 - 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