博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Can't connect to MySQL server on 'ip' (13)
阅读量:7221 次
发布时间:2019-06-29

本文共 1237 字,大约阅读时间需要 4 分钟。

hot3.png

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 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

转载于:https://my.oschina.net/dongqianlin/blog/75031

你可能感兴趣的文章
第十周web作业2:Object的起源
查看>>
ThunderBird, NewsBlog部分代码阅读笔记
查看>>
BZOJ1034[ZJOI2008]泡泡堂
查看>>
Protocol Buffers 介绍
查看>>
netty对http协议解析原理解析(转载)
查看>>
IaaS, PaaS和SaaS
查看>>
sql 查找死锁对象的存储过程
查看>>
详解Oracle数据字典
查看>>
多线程消息监听容器配置[ 消费者spring-kafka配置文件]
查看>>
OOD
查看>>
LR 中webservice三种使用方法
查看>>
[WinForm] C#避免Panel(ScrollableControl)的子控件获取焦点时滚动条自动滚动
查看>>
学习php需要走的路
查看>>
SCCM2012系列之六,SCCM2012部署前的WDS准备
查看>>
晒一晒老司机写的“超融合私有云”解决方案
查看>>
写在11期培训班第五次课后作业前面的话
查看>>
Office365:客户端升级后无法启动Microsoft Outlook
查看>>
Zabbix监控之邮件发送失败-smtp-server: 错误代码550与535
查看>>
MySQL 读写分离介绍及搭建
查看>>
Intellij IDEA 部署 Spring Boot / Spring Cloud 应用到阿里云
查看>>