mrj Posted May 12, 2019 Posted May 12, 2019 Why I am getting following error:SQLSTATE[HY000] [1203] User mrj_user already has more than 'max_user_connections' active connectionsI guess it is something about sql connections are eating up by scripts. I want to know how and which scripts are responsible. Please admins, help me.
Luigi123 Posted May 12, 2019 Posted May 12, 2019 Also, a lot of users forget to close the mysql connections when they have finish working on it. So that maybe the problem you forget to close the mysql connections and that is why you got that error.
mrj Posted May 12, 2019 Author Posted May 12, 2019 My db class have a __destruct function which is closing database connection.
Luigi123 Posted May 12, 2019 Posted May 12, 2019 Oh I see. We’ll wait for Krydos and see what he says. 1
mrj Posted May 14, 2019 Author Posted May 14, 2019 But I get this error too often. Any suggestion how I monitor and fix this problem?
wolstech Posted May 14, 2019 Posted May 14, 2019 It's either your script, or you're receiving too much concurrent traffic. I see this error quite a bit with the HelioMine/RGS API that I run, and it's caused by too many clients hitting it at once (in my case the occasional failure from too many connections is acceptable since the clients retry on their own). You mentioned closing your connections in __destruct()...does your script open more than one though? Just because it's closing them doesn't mean it won't run out of connections while running. Open a single connection at startup, and reuse that connection throughout the entire program. Close it on exit. Avoid doing things like opening a new connection for each instance of a class and closing it when the object is destroyed. If it's the second issue, it means you've outgrown shared hosting (very easy to do if you're receiving a decent amount of traffic and use heavy software) and should consider buying a VPS instead. While it's not free, you get full root access to do whatever you please, so running out of connections won't be an issue.
lanied Posted May 15, 2019 Posted May 15, 2019 I get that error often too when i work with workbench , I solve my problem by logging in to phpmyadmin in my Cpanel and execute the command "show processlist;" , then I kill those connections in the "kill" option
Recommended Posts