MySQL: Too Many Connections


#1

In the process of troubleshooting a script I get this error message when I ‘retry’ the install:

Warning: MySQL Connection Failed: Too many connections in /home/.kelev/user/domain/application/DB.php on line 25

I think this may be because I misunderstood the phpMyAdmin logout and probably actually logged myself in multiple times. Is that even possible? How do I clear connections, assuming that’s what I need to do?


#2

The error is correct. You simply have too many connections open. :slight_smile:

Be careful here with PHP. Make sure you close() your connections after opening them. Maybe a look at the source code in question can help us determine what’s wrong, but I’d put my money on you not closing your opened connections properly and therefore running out of your available connection pool.

BTW: This is a very bad thing for the MySQL server. You should take care when working with databases from PHP to make sure that you finish off all your persistent database connections or you can land the server in some trouble.

  • wil

#3

Eeek. I’ll open a support ticket to ask someone to take a look. I don’t want my install failure impacting anyone else.


#4

If it isn’t sensitive code in any way (i.e. strip usernames / passwords and any file paths out of code) then you’re more than welcome to post it here so that someone can take a look for you.

  • wil

#5

Thanks for the offer; with the author’s help I was able to install finally. It was a purchased script and nothing I wrote.

I wasn’t as concerned about the script per se so much as that I was somehow using up all my connections trying to log out of phpMyAdmin. (Clicking Log Out brings up the Log In dialogue. There seems to be no escape short of closing the browser window; selecting Cancel says “Welcome to phpMyAdmin, sorry your authentication failed” or words to that effect. It seemed odd to require a password to log out, but I admit I filled in the dialogue more than once. I’m SO literal-minded.) I then panicked and wondered if I’d started three or four instances of phpMyAdmin none of which could be stopped. Or not.

I’m not sure at this point if I may just have been affected by whatever was going on. I had a dread fear I might be the one CAUSING the problem. All I got from support when I asked them to see if I might be the guilty party was an apology for the inconvenience. I would imagine if I was the problem I would have been ‘spanked’ by email. As the day is young yet, I could still be in for a spanking later I suppose. <-- cue Monty Python and The Holy Grail scene recitation :slight_smile:

haggis


#6

this was sent out tonight –

The following is a Informational announcement, sent 2002-07-30 21:07:51.

You are receiving it via email because it is level 4 and
your account is set to get announcements of that level via email.
You can change that by visiting our web panel’s announcement
area at: https://panel.dreamhost.com/?tab=status&subtab=announce

Hello MySQL Users!

Over the past several days, you may have experienced intermittent problems
relating to the maximum number of connections to your MySQL server being
exceeded. This would have resulted in your site not being able to connect
to your mysql server (thereby breaking your site, at least on a percentage
of page loads).

We’ve tracked down the problem to one particular user who was consuming a
large number of connections (about 50% of the available connections).
We’ve done the following to permanently alleviate the problem:

  • Moved that user off the troubled mysql instance onto his own (for now)
  • Increased the maximum number of available connections by 50%
  • Lowered the length of time a sleeping connection is kept to 4 hours
    (this will speed up the rate at which connections become
    available)
  • Instituted a new policy & configuration which only allows a maximum
    of 25% of the total available connections per user. This will prevent
    one user from “stepping” on all the other users.

These changes will most definitely prevent this problem from recurring again.

We’re very sorry for any inconvenience this may have caused you.

Happy DreamHost MySQL Team!


Thank you for taking the time to read this announcement,
The DreamHost Announcement Team


#7

Can you tell me what to look for/do to make sure my connections are closed if need be?