<? $link=mysql_pconnect("localhost","root",""); mysql_select_db("MFTDB",$link); $str="select password from users where user='ANDY'"; $result=mysql_query($str,$link); if (mysql_num_rows($result)>0): list($password)=mysql_fetch_row($result); echo "password:".$password; endif; ?> 上面的代码是在php+mysql+apache+linux下的,我就在相同IP的机上,用5个(或更多的)IE打开上面的页面,mysql中就会有5条连接(或更多),也就是开一次会多一条,我不知是怎么回事,最后也会出现也会出现“Too many connections”这个错误,只能关mysql数据库。mysql_pconnect不是永久连接吗,怎么存在这个连接还会去新建?????????????
Warning Using persistent connections can require a bit of tuning of your Apache and MySQL configurations to ensure that you do not exceed the number of connections allowed by MySQL.
另外不要频繁close()
还有就是尽量加大内存如果问题没有解决,请加上启动参数
vi /etc/rc.d/rc.local
safe_mysqld -O max_connections=500 &
就行了
总之很多方法的!!自己搜索一下这里
也许是别人连接的同一个MySQL服务器的人数过多,
我在用freesql.org上的MySQL服务器连接时就有时会出现问题。
你的网址是?
$link=mysql_pconnect("localhost","root","");
mysql_select_db("MFTDB",$link);
$str="select password from users where user='ANDY'";
$result=mysql_query($str,$link);
if (mysql_num_rows($result)>0):
list($password)=mysql_fetch_row($result);
echo "password:".$password;
endif;
?>
上面的代码是在php+mysql+apache+linux下的,我就在相同IP的机上,用5个(或更多的)IE打开上面的页面,mysql中就会有5条连接(或更多),也就是开一次会多一条,我不知是怎么回事,最后也会出现也会出现“Too many connections”这个错误,只能关mysql数据库。mysql_pconnect不是永久连接吗,怎么存在这个连接还会去新建?????????????
Using persistent connections can require a bit of tuning of your Apache and MySQL configurations to ensure that you do not exceed the number of connections allowed by MySQL.