Hello all,
This isn’t a strictly MySQL issue, it has to do also with PHP Apache and cPanel but I believe the core is MySQL so I decided to post it here.
Recently I had a SQLSTATE[08004] [1040] Too many connections issue. I use PHP PDO for the connection and from the PHP PDO manual I know that “PHP will automatically close the connection when your script ends”.
From phpMyAdmin information_schema GLOBAL_STATUS table I see.
ABORTED_CLIENTS 3589
ABORTED_CONNECTS 27319

From SHOW VIRABLES statement I see
max_connect_errors 20
max_connections 150
max_user_connections 25

I am thinking on how to fix the “Too many connections” issue. Should I try to set global max_connections more then 150? One other approach is to create more users for the database and then the web application to select randomly witch one to use. Would this help fixing the issue? Until know I have avoided making persistent connections with the use of PDO::ATTR_PERSISTENT should I re-examine that?

I understand that I should consider moving to VPS or Dedicated Server Hosting and maybe I will, but first I must understand how things work. In cPanel/Databases/MySQL Databases you can add new MySQL users. The max_user_connections refers to that or to cPanel account (all the users you create) ?.

Thank you in advance for your responses,

Hi

I had some same issues a while back. In my opinion, this is not related to the users you create on your database or your cpanel. It has to do with your hosting service, especially if you are hosted on a shared server. This is a issue of the MySQL server itself, where your databse is hosted on.

Normally, this issue last only a few minutes, and then correct itself. If it is a constant issue with you, I reccomend you upgrade your hosting to a vps.

The best is, as soon as this happens, to contact your hosting company. They can reset the server if you cannot do it from your end.

..... sorry, duplicate post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.