为什么网站最近经常出现“链接过多”的问题,刷新一下就好了。页面的,mysql_query()太多是不是就会引起这样的问题呢?怎么回事啊
解决方案 »
- 咨询一下,用VS2010连接MYSQL的时候报错(找不到请求的.net framework data provider。可能没有安装)
- mysql怎么打补丁啊?
- update 很慢 有不有其它的语句替代,或者说用储存过程?
- 求救mysql优化问题
- 在win32下,怎样对mysql的表结构进行更改,有没有可视化的工具?以及怎样数据备份
- 我的apache2+php+mysql出现的问题
- bigint中的字段长度设为20有问题
- 关于mysql-installer-community-5.5.36.0的细节问题
- mysql乱码问题,要逼疯了
- mysql主从复制:数据中的字符很大,数据量也大,所有要用slave_exec_mod,具体怎么做,别随便给我一些资料,我要的是具体的对主从服务器的操作
- 如何建这样的表
- 急求 股票sql
而MYSQL中对最大连接数是有限制的。你可以修改max_connections 参数以加大并发连接数。但最好先找到原因,为什么这么多连接请求,是不是在使用完后没有及时释放连接?
<?
#############
#数据库链接类#
#############class data_class{
private $data_name;
private $user_name;
private $user_pass;
private $data_address;
private $conn;function __get($property_name){
if(isset($this->$property_name)){
return ($this->$property_name);
}else{
return (NULL);
}
}function __set($property_name,$value){
$this->$property_name=$value;
}function __construct($ip,$data,$user,$pass){
$this->data_address=$ip;
$this->data_name=$data;
$this->user_name=$user;
$this->user_pass=$pass;
$this->conn=mysql_connect($this->data_address,$this->user_name,$this->user_pass) or die("
<?xml version=\"1.0\" encoding=\"utf-8\"?>\n
<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">\n
<html xmlns=\"http://www.w3.org/1999/xhtml\">\n
<head>\n
<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\"/>\n
<meta http-equiv=\"Cache-Control\" content=\"ust-revalidate\" forua=\"true\"/>\n
<meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/>\n
<meta http-equiv=\"Cache-Control\" content=\"max-age=0\" forua=\"true\"/>\n
<meta http-equiv=\"Expires\" content=\"0\" forua=\"true\"/>\n
<meta http-equiv=\"Pragma\" content=\"no-cache\" forua=\"true\"/>\n
<link rel=\"shortcut icon\" href=\"/favicon.ico\" />\n
<title>网站维护中</title>
</head>
<body>
网站正在升级.....请稍后访问……<br/>
<body>
</html>
");
mysql_query("set names 'utf8'",$this->conn);
mysql_select_db("$this->data_name",$this->conn);
}
function __destruct(){
mysql_close($this->conn);
}}
?>
mysql_free_result 只是释放结果集,并不是关闭连接。
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 151 |
+-------------------+
1 row in set (0.00 sec)
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| 151 |
+-------------------+
1 row in set (0.00 sec)这个能运行的哦