Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

exception ‘Zend_Db_Adapter_Exception’
 
adityak
Member
 
Total Posts:  63
Joined:  2008-02-10
India
 

Im facing this problem repeatedly.
Can someone explain to me what is causing this error?
Whenever i try to load the admin or storefront i get this error in my browser:

exception ‘Zend_Db_Adapter_Exception’ with message ‘SQLSTATE[00000] [1040] Too many connections’ in /var/www/html/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php:131
Stack trace:
#0 /var/www/html/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(91): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /var/www/html/magento/lib/Zend/Db/Adapter/Abstract.php(380): Varien_Db_Adapter_Pdo_Mysql->_connect()
#2 /var/www/html/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(206): Zend_Db_Adapter_Abstract->query(’SET NAMES utf8’, Array)
#3 /var/www/html/magento/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(32): Zend_Db_Adapter_Pdo_Abstract->query(’SET NAMES utf8’)
#4 /var/www/html/magento/app/code/core/Mage/Core/Model/Resource.php(71): Mage_Core_Model_Resource_Type_Db_Pdo_Mysql->getConnection(Object(Mage_Core_Model_Config_Element))
#5 /var/www/html/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(47): Mage_Core_Model_Resource->getConnection(’core_setup’)
#6 /var/www/html/magento/app/code/core/Mage/Core/Model/Resource/Setup.php(93): Mage_Core_Model_Resource_Setup->__construct(’core_setup’)
#7 /var/www/html/magento/app/code/core/Mage/Core/Model/Config.php(165): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#8 /var/www/html/magento/app/code/core/Mage/Core/Model/App.php(179): Mage_Core_Model_Config->init(NULL)
#9 /var/www/html/magento/app/Mage.php(358): Mage_Core_Model_App->init(’base’, NULL)
#10 /var/www/html/magento/app/Mage.php(378): Mage::app(’base’, NULL)
#11 /var/www/html/magento/index.php(29): Mage::run(’base’)
#12 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
etho201
Sr. Member
 
Total Posts:  85
Joined:  2008-04-03
Summerville, SC
 

I know you posted this a while back… but I’m getting the same problem as you. “Too many connections” Did you ever figure out a way to fix this problem?

Then I tried visiting the site a few minutes later and I get the following error:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

#0 /home/user001/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(130): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /home/user001/public_html/lib/Zend/Db/Adapter/Abstract.php(390): Varien_Db_Adapter_Pdo_Mysql->_connect()
#2 /home/user001/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(206): Zend_Db_Adapter_Abstract->query('
SET NAMES utf8', Array)
#3 /home/user001/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(193): Zend_Db_Adapter_Pdo_Abstract->query('
SET NAMES utf8', Array)
#4 /home/user001/public_html/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(39): Varien_Db_Adapter_Pdo_Mysql->query('
SET NAMES utf8')
#5 /home/user001/public_html/app/code/core/Mage/Core/Model/Resource.php(77): Mage_Core_Model_Resource_Type_Db_Pdo_Mysql->getConnection(Object(Mage_Core_Model_Config_Element))
#6 /home/user001/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(242): Mage_Core_Model_Resource->getConnection('
core_read')
#7 /home/user001/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(257): Mage_Core_Model_Mysql4_Abstract->_getConnection('
read')
#8 /home/user001/public_html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(277): Mage_Core_Model_Mysql4_Abstract->_getReadAdapter()
#9 /home/user001/public_html/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php(62): Mage_Core_Model_Mysql4_Abstract->getReadConnection()
#10 /home/user001/public_html/app/code/core/Mage/Core/Model/Config.php(715): Mage_Core_Model_Mysql4_Collection_Abstract->__construct(Object(Mage_Core_Model_Mysql4_Website))
#11 /home/user001/public_html/app/code/core/Mage/Core/Model/Config.php(757): Mage_Core_Model_Config->getModelInstance('
core_mysql4/web...', Object(Mage_Core_Model_Mysql4_Website))
#12 /home/user001/public_html/app/Mage.php(315): Mage_Core_Model_Config->getResourceModelInstance('
core/website_co...', Object(Mage_Core_Model_Mysql4_Website))
#13 /home/user001/public_html/app/code/core/Mage/Core/Model/Abstract.php(185): Mage::getResourceModel('
core/website_co...', Object(Mage_Core_Model_Mysql4_Website))
#14 /home/user001/public_html/app/code/core/Mage/Core/Model/Abstract.php(190): Mage_Core_Model_Abstract->getResourceCollection()
#15 /home/user001/public_html/app/code/core/Mage/Core/Model/App.php(355): Mage_Core_Model_Abstract->getCollection()
#16 /home/user001/public_html/app/code/core/Mage/Core/Model/App.php(233): Mage_Core_Model_App->_initStores()
#17 /home/user001/public_html/app/Mage.php(397): Mage_Core_Model_App->init('', '
store', Array)
#18 /home/user001/public_html/app/Mage.php(416): Mage::app('', '
store', Array)
#19 /home/user001/public_html/index.php(46): Mage::run()
#20 {main}
 
Magento Community Magento Community
Magento Community
Magento Community
 
etho201
Sr. Member
 
Total Posts:  85
Joined:  2008-04-03
Summerville, SC
 

As usual, I may have found my own solution (via a quick search on google). Here’s an explanation of the problem and a possible fix just in case anyone else has an issue with this.

If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.

The number of connections allowed is controlled by the max_connections system variable. Its default value is 100. If you need to support more connections, you should set a larger value for this variable.

By default, mine was set at 800… So I just doubled the number:

Open /etc/my.cnf
set-variable = max_connections=800

change to:
set-variable = max_connections=1600

Be sure you put this under the [mysqld] section.

Some other suggestions that my help remedy the issue…

Another symptom for PHP users, the “max_connections” error being returned to the browsers and the “show processlist” filling up with sleeping threads: This can sometimes be alleviated by using the PHP .htaccess option to lower the connect timeout from the default 60 seconds.

php_value mysql.connect_timeout 20

A lot of sites only suffer from this problem when Google or any other search bot is visiting. The best way to resolve this is to add the ‘Crawl-delay’ parameter in your robots.txt or to set it to a higher number of seconds.

Open robots.txt
User-Agent: *
Crawl-Delay: 10

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top