Hello,
Sometime when I want to browse my website, the "SQLSTATE[HY000] [1040] Too many connections" error appeared.
Trace: #0 /srv/MyWebsite/public/lib/Zend/Db/Adapter/Pdo/Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect() #1 /srv/MyWebsite/public/lib/Varien/Db/Adapter/Pdo/Mysql.php(396): Zend_Db_Adapter_Pdo_Mysql->_connect() #2 /srv/MyWebsite/public/lib/Zend/Db/Adapter/Abstract.php(460): Varien_Db_Adapter_Pdo_Mysql->_connect() #3 /srv/MyWebsite/public/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array) #4 /srv/MyWebsite/public/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array) #5 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource.php(179): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8') #6 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element)) #7 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write') #8 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract->_getConnection('write') #9 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(335): Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter() #10 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(360): Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter() #11 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(134): Mage_Core_Model_Resource_Db_Abstract->getReadConnection() #12 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website)) #13 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('core_resource/w...', Object(Mage_Core_Model_Resource_Website)) #14 /srv/MyWebsite/public/app/Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('core/website_co...', Object(Mage_Core_Model_Resource_Website)) #15 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Abstract.php(208): Mage::getResourceModel('core/website_co...', Object(Mage_Core_Model_Resource_Website)) #16 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection() #17 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/App.php(619): Mage_Core_Model_Abstract->getCollection() #18 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/App.php(477): Mage_Core_Model_App->_initStores() #19 /srv/MyWebsite/public/app/code/core/Mage/Core/Model/App.php(360): Mage_Core_Model_App->_initCurrentStore('', 'store') #20 /srv/MyWebsite/public/app/Mage.php(684): Mage_Core_Model_App->run(Array) #21 /srv/MyWebsite/public/index.php(82): Mage::run('', 'store') #22 {main}
The MySQL config is:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-show-database # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used (fedora >= 15). # If you need to run mysqld under a different user or group, # customize your systemd unit file for mysqld according to the # instructions in http://fedoraproject.org/wiki/Systemd user=mysql # Semisynchronous Replication # http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html # uncomment next line on MASTER ;plugin-load=rpl_semi_sync_master=semisync_master.so # uncomment next line on SLAVE ;plugin-load=rpl_semi_sync_slave=semisync_slave.so # Others options for Semisynchronous Replication ;rpl_semi_sync_master_enabled=1 ;rpl_semi_sync_master_timeout=10 ;rpl_semi_sync_slave_enabled=1 # http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html ;performance_schema [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid # # include all files from the config directory # !includedir /etc/my.cnf.d bind-address = 127.0.0.1 local-infile=0
What is my problem?
Please look at:
https://pasteboard.co/IGjzewW.png
The memory is full
Thanks.
Hi @jason_long,
You need to increase the memory limit on the server.
For the quick fix, just restart the server and mysql.
I hope it will help you!
Hi @jason_long,
check the below stack link.
https://stackoverflow.com/a/24225501
I hope it will help you!
Is "max_connections" mandatory?
I think yes, because there is already a default value for max connection on server level.
Hi @jason_long
Please run following command in MySql
show variables like 'max_connections';
It will show maximum connections allowed at a time.
Based on your requirement you can update the value.
In your MySql's my.cnf file you can set the desired value.
For example to set 200 value max_connections = 200
Please refer following articles which will help you.
https://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
https://www.percona.com/blog/2013/11/28/mysql-error-too-many-connections/