咨询关于mysql_connect超时连接
连接代码,以下简化的生产代码
$start_time = date('Y-m-d H:i:s');
if(mysql_connect($config['dbhost'], $config['dbuser'], $config['dbpw'], TRUE)){
// something code
}else{
error_log('['. date('Y-m-d H:i:s') .'] 连接失败'.$this->error().' start='.$start_time.' host='.$config['dbhost'].' user='.$config['dbuser']."\n", 3, UC_ROOT.'logs/sqlerr_'.date('Y-m-d').'.log');
}
连接超时日志,有个规律是7秒这个值
[2014-12-17 21:10:37] 连接失败Connection timed out start=2014-12-17 21:10:30 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:11:15] 连接失败Connection timed out start=2014-12-17 21:11:08 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:16:35] 连接失败Connection timed out start=2014-12-17 21:16:28 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:34:55] 连接失败Connection timed out start=2014-12-17 21:34:48 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:46:55] 连接失败Connection timed out start=2014-12-17 21:46:48 host=192.168.1.6:3306 user=cuser
[2014-12-17 21:47:24] 连接失败Connection timed out start=2014-12-17 21:47:17 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:15:28] 连接失败Connection timed out start=2014-12-17 22:15:21 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:38:20] 连接失败Connection timed out start=2014-12-17 22:38:13 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:38:54] 连接失败Connection timed out start=2014-12-17 22:38:47 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:39:41] 连接失败Connection timed out start=2014-12-17 22:39:34 host=192.168.1.6:3306 user=cuser
[2014-12-17 22:52:20] 连接失败Connection timed out start=2014-12-17 22:52:13 host=192.168.1.6:3306 user=cuser
[2014-12-17 23:21:54] 连接失败Connection timed out start=2014-12-17 23:21:47 host=192.168.1.6:3306 user=cuser
以下为部分长ping数据
PING 192.168.1.6 (192.168.1.6) 56(84) bytes of data.
64 bytes from 192.168.1.6: icmp_seq=1 ttl=64 time=0.158 ms
64 bytes from 192.168.1.6: icmp_seq=2 ttl=64 time=0.142 ms
64 bytes from 192.168.1.6: icmp_seq=3 ttl=64 time=0.153 ms
64 bytes from 192.168.1.6: icmp_seq=4 ttl=64 time=0.137 ms
64 bytes from 192.168.1.6: icmp_seq=5 ttl=64 time=0.203 ms
64 bytes from 192.168.1.6: icmp_seq=6 ttl=64 time=0.150 ms
64 bytes from 192.168.1.6: icmp_seq=7 ttl=64 time=0.139 ms
64 bytes from 192.168.1.6: icmp_seq=8 ttl=64 time=0.137 ms
64 bytes from 192.168.1.6: icmp_seq=9 ttl=64 time=0.201 ms
以下为部分php.ini部分参数设置信息
php.ini
max_execution_time = 30
max_input_time = 60
default_socket_timeout = 60
mysql.connect_timeout => 60 => 60
default_socket_timeout => 60 => 60
相关推荐
详解Python连接MySQL数据库的多种方式
如果遇到无法连接的问题,首先检查账号是否有权限,必要时咨询数据库管理员。
校园二手交易Android项目源码解析:SpringBoot与MySQL全链路实现
在移动应用开发中,客户端与服务端的数据交互是构建完整业务闭环的基石。理解RESTful API设计、数据库事务管理、网络请求封装等技术原理,能够显著提升开发者从零搭建工程的能力。基于SpringBoot、MySQL和Android客户端的三层架构,不仅适用于电商类应用,也是校园二手交易平台等场景的典型解决方案。这类系统通过统一的HTTP接口实现多端复用,配合Token鉴权、图片压缩、分页查询等工程实践,能够高效支撑商品发布、订单流转、实时聊天等高频功能。本文从技术原理出发,结合一个包含Android客户端、
Can't connect to MySQL server on 'localhost' (10048)问题解决方法
当在Windows 2003服务器环境下,运行PHP时遇到"Can't connect to MySQL server on 'localhost' (10048)"错误时,这意味着本地MySQL服务器没有被成功连接
KB967723补丁造成的MYSQL在Win2003上频繁连接不上的问题的解决方法
具体表现为:“Can't connect to MySQL server on ‘localhost' (10061)”错误提示。
MySQL实现远程登录的方法
如果你不确定如何配置防火墙,建议咨询服务器管理员。第二步是通过 MySQL 的管理工具增加允许远程连接的用户并进行授权。首先,你需要以 MySQL 的 root 用户身份登录。


基础编程
