大家好.我有一个奇怪的错误.我创建了一个这样的聊天:
Good day to all. I have an odd error. I have created a chat that works like this:
直到今天我收到此错误时它都运行良好:
It worked fine until today when I got this error:
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1040] Too many connections' in /var/www/html/dbdev/include/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace: #0 /var/www/html/dbdev/include/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:host=loca...', '', '', Array)
s#1 /var/www/html/dbdev/include/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
s#2 /var/www/html/dbdev/include/Zend/Db/Adapter/Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect()
s#3 /var/www/html/dbdev/include/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('select profile_...', Array)
s#4 /var/www/html/dbdev/include/Zend/Db/Adapter/Abstract.php(782): Zend_Db_Adapter_Pdo_Abstract->query('select profile_...', Array)
s#5 /var/www/html/dbdev/include/Profile.php(43): Zend_Db_Adapter_Abstract->fetchPairs('select profile_...')
s#6 /var/www/html/dbdev/public_html/index.php(29): Profile->load()
s#7 {main} Next exception 'Zend_Db_Adapter_Exception' with in /var/www/html/dbdev/include/Zend/Db/Adapter/Pdo/Abstract.php on line 144
问题是我们没有那么多...(8)而且我认为数据库不能同时支持超过 8 到 16 个连接(在规范上写的是聊天必须支持 50-100 个用户所以8是......小).
The problem is that we were not that many... (8) and I don't think the db could not support more than 8 to 16 connections simultaneously (on specifications is written that the chat must support 50-100 users so 8 is... small).
所以...谁能告诉我为什么会发生这种情况(昨天我们 15 岁并且工作正常)以及如何解决它?谢谢您的帮助.如果您需要任何代码示例,请询问.
So... can any1 tell me why did this happen (yesterday we were 15 and worked fine) and how to solve it? Thank you for your help. If you need any code samples just ask.
Too Many Connections"错误的原因有很多.
There are a bunch of different reasons for the "Too Many Connections" error.
在 MySQL.com 上查看此常见问题解答页面:http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
Check out this FAQ page on MySQL.com: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
检查您的 my.cnf 文件中的max_connections".如果不存在尝试:
Check your my.cnf file for "max_connections". If none exist try:
[mysqld]
set-variable=max_connections=250
但是默认值是 151,所以你应该没问题.
However the default is 151, so you should be okay.
如果您在共享主机上,可能是其他用户占用了太多连接.
If you are on a shared host, it might be that other users are taking up too many connections.
需要注意的其他问题是持久连接的使用和磁盘空间不足.
Other problems to look out for is the use of persistent connections and running out of diskspace.
这篇关于php, mysql - 数据库连接过多错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!