{"id":836,"date":"2024-06-29T06:17:34","date_gmt":"2024-06-29T06:17:34","guid":{"rendered":"https:\/\/linuxresellerwebhosting.in\/blog\/?p=836"},"modified":"2024-06-29T06:28:38","modified_gmt":"2024-06-29T06:28:38","slug":"fix-mysqli_sql_exception-too-many-connections","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/fix-mysqli_sql_exception-too-many-connections\/","title":{"rendered":"Fix: mysqli_sql_exception too many connections"},"content":{"rendered":"<p>Here in this article you will know how to fix mysqli_sql_exception too many connections in cpanel<\/p>\n<h2 id=\"h_01HA9E5MF04727BADCAS7F87S2\">Error mysqli_sql_exception too many connections<\/h2>\n<p>You may receive errors like the following on your website, or\u00a0when trying to access MySQL from the command line or phpMyAdmin.<\/p>\n<pre class=\"error\">mysqli_connect(): (08004\/1040): Too many connections<\/pre>\n<pre>mysqli_real_connect(): (HY000\/1040): Too many connections<\/pre>\n<pre>PHP Warning: mysqli::__construct(): (08004\/1040): Too many connections in<\/pre>\n<pre>mysqli_sql_exception too many connections<\/pre>\n<p>When a MySQL server is initially installed, it will have\u00a0<strong>150<\/strong>\u00a0as the default value for maximum permitted number of simultaneous client connections. This value can be adjusted further in servers.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-842 size-full\" src=\"https:\/\/linuxresellerwebhosting.in\/blog\/wp-content\/uploads\/2024\/06\/sql-error.jpg\" alt=\"mysqli_sql_exception too many connections\" width=\"847\" height=\"502\" srcset=\"https:\/\/linuxresellerwebhosting.in\/blog\/wp-content\/uploads\/2024\/06\/sql-error.jpg 847w, https:\/\/linuxresellerwebhosting.in\/blog\/wp-content\/uploads\/2024\/06\/sql-error-300x178.jpg 300w, https:\/\/linuxresellerwebhosting.in\/blog\/wp-content\/uploads\/2024\/06\/sql-error-768x455.jpg 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/p>\n<p>An additional admin connection is also possible to monitor these client connections.\u00a0This extra connection is reserved for use by accounts that have CONNECTION_ADMIN\u00a0or SUPER user\u00a0privilege.<\/p>\n<p>The number of connections is defined by<strong> \u2018max_connections\u2019<\/strong> value.\u00a0When the number of client connections exceed this value, MySQL shows \u2018Too many connections\u2019 error.<\/p>\n<p>This can happen in multiple scenarios, and the fix for the error would vary with the actual cause. Here, we\u2019ll see the various causes that trigger\u00a0MySQL \u2018Too many connections\u2019 error.<\/p>\n<p>Your MySQL database only allows so many connections at the same time. If you connect to MySQL via PHP, then you generally open a new connection every time a page on your site loads. So if you&#8217;ve got too much traffic to your site this can cause this issue.<\/p>\n<p>General procedure and fix,<\/p>\n<p>The default <code>max_connections<\/code> setting for MySQL is <code>151<\/code>. For some servers, this setting may need adjusting. This article provides the procedure to adjust this setting.<\/p>\n<p>Access the server&#8217;s command line as the &#8216;root&#8217; user via SSH or &#8220;Terminal&#8221; in WHM.<br \/>\nCheck the current max_connections setting.<\/p>\n<pre>[root@server ~]cPs# mysql -e \"show variables like 'max_connections';\"\r\n+-----------------+-------+\r\n| Variable_name | Value |\r\n+-----------------+-------+\r\n| max_connections | 100 |\r\n+-----------------+-------+<\/pre>\n<p>Open \/etc\/my.cnf in your preferred text editor.<br \/>\nLocate the max_connections entry or add the entry to the end of the file if one doesn&#8217;t exist.<\/p>\n<pre>max_connections=151<\/pre>\n<p>Set the max_connections value to the desired value.<br \/>\nSave the changes and exit the text editor.<br \/>\nRestart the MySQL service.<\/p>\n<pre>\/usr\/local\/cpanel\/scripts\/restartsrv_mysql<\/pre>\n<p>Verify that the max_connections setting has been updated.<\/p>\n<pre>[root@server ~]cPs# mysql -e \"show variables like 'max_connections';\"\r\n+-----------------+-------+\r\n| Variable_name | Value |\r\n+-----------------+-------+\r\n| max_connections | 150 |\r\n+-----------------+-------+<\/pre>\n<p>&nbsp;<\/p>\n<p>If the mails are not delivering and in queue , you don&#8217;t know how to delete pending mail in Exim queue <a href=\"https:\/\/linuxresellerwebhosting.in\/blog\/pending-mail-in-the-exim-queue\/\">click here.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here in this article you will know how to fix mysqli_sql_exception too many connections in cpanel Error mysqli_sql_exception too many<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[1],"tags":[],"class_list":["post-836","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=836"}],"version-history":[{"count":8,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/836\/revisions"}],"predecessor-version":[{"id":845,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/836\/revisions\/845"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}