Jump to content

Recommended Posts

Posted

I've been getting a fair amount of max user connection errors in mysql lately.

 

I imagine that most of this is due to how I'm currently using mysql. I currently have 4 databases, and I'm opening/closing connections a lot. This is because I wish to make nifty classes/interfaces that I can slap into any future project with independent DBs. I'm guessing after almost OCD level code review that mysql can't keep up at times as the error appears at random points in execution.

 

I can of course whack everything into the same DB, but that defeats the purpose of what I eventually wish to accomplish.

 

Anyhow, I noticed that max user connections is set to 2. Would there be a huge impact to the server if this was increased to 3? I imagine this would solve my problem. If not, I'll just make the necessary changes, but it would be nice if possible.

Posted

Do all of your different DBs have different users and passwords? If they all use the same user then you only need to open one connection and select the database needed to perform whatever task. Example:

<?php
$dbcon = mysql_connect("localhost","user","password");

mysql_select_db("db2", $dbcon);
// action on DB1

mysql_select_db("db2", $dbcon);
// action on DB2

mysql_close($dbcon);
?>

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...