dukeispie dukeispie - 1 year ago 93
MySQL Question

max_user_connections error, what does it mean?

So my website is currently exploding right now.
In my header.php (logged in users only have) checks if there is an mysql_error.
If one is found, it destroys the session and outputs:

Sorry, something went wrong


In this case, it outputs:

Sorry, something went wrong
User duavatar_dba already has more than 'max_user_connections' active connections

Other Notes
There is a Session Variable that is created when the user logs in, and the value is the user's id (auto_increment) in the database. When header.php is trying to find the ID in the database from
, it (very rarely) pops up with "Sorry, something went wrong", then the

The code that outputs this error is

$fetchuser = "SELECT * FROM `duavatar_db`.`users` WHERE `users`.`id`=".$_SESSION['id'];
$exec = mysql_query($fetchuser, $con);
if(mysql_num_rows($exec) == 0){
die("Sorry, something went wrong.<hr>".mysql_error());

YES, $con IS A DEFINED VARIABLE. duavatar_dba is the mysql account username.

This error commonly occurs if an ID was swapped, or the account you have logged in with was just manually removed from the database.
What I want I would like to know what "max_user_connections" is, and how to change the amount of "max connections" (if possible).

sg- sg-
Answer Source

That's a MySQL setting which limits the number of connections that a single user can have to the database at any one time. Your PHP application generally connects to the database using a single user account - For example The one you use in the statement:


You're traffic is obviously exceeding the number of allowed connections.

Increase the value using these instructions:


For example, if you want to increase the maximum number of connections to 20:

ALTER USER 'your_user'@'your_host' WITH MAX_USER_CONNECTIONS 20;

Don't accidently reduce the number though. Check the current value using this query:

SELECT * FROM mysql.user;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download