I have a local apache server for development, but the application accesses a remote mysql server.

I tried opening my app and it said: Warning: mysql_connect(): Too many connections in /myconnection/... on line 2
Could not connect to database

Then I tried logging on with the same username to that server with PHP MyAdmin and got this message:
Error: #1040 - Too many connections

Is this a general "too many connections" problem on my host provider, or is it from my own connections over the past months that have "built up"? And if the latter is the case how do I fix it?

[EDIT]I just tried connecting via OSX Terminal with my usual command: /usr/local/mysql/bin/mysql database -u username -h mysql.mysite.net -p.. and IT LET ME CONNECT NO PROBLEM. So then, I thought, hey maybe I can access the app or go to myadmin and still NOT![/EDIT]

[EDIT2]OK, I just tried querying from terminal and no luck. ALSO, I tried connecting to another database (is the word "daemon"??) with the same host and got the same error[/EDIT2]

Well, that was fun and we all had a jolly good time, I say!

    I hope it's working out, but i recently had this same problem.

    I noticed that one developer who had written some code for our server was using pconnect. persistent connections might be part of your problem.

    another possibility is that you have your mysql/php system set up for some low number of connections. i think 100 is default but i'm not sure about that.

    our server was set at 20 for some reason. googling is helpful for more info.

      My own experience is that mysql_pconnect is very buggy and the connections are NOT reused when the server is under high load.

        Hi!!

        {from Manual}

        If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.

        The number of connections allowed is controlled by the max_connections system variable. Its default value is 100. If you need to support more connections, you should restart mysqld with a larger value for this variable.

        mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected. See Section

        The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform. Linux or Solaris should be able to support 500-1000 simultaneous connections, depending on how much RAM you have and what your clients are doing. Static Linux binaries provided by MySQL AB can support up to 4000 connections.

        In detail

        http://dev.mysql.com/doc/mysql/en/too-many-connections.html

          Thanks friendly people! 🙂

          Here I my two questions of the moment:

          1. My host is a "shared host". Does that mean that the mysql server is also shared and therefore everybody shares the same client load?? or do I have my own "server"?

          2. Which leads to the next question. What is a "daemon"?

          3. Well ok, three questions: Does anyone know of a good affordable host that is not "shared", so that I can't get bumped by other people's clients???

          4. Darn I just can't stop thinking of questions! OK, what do you people do (general script logic) as far as protecting your apps from dieing a horrible death if the database is down??

            1) that would depend on how your box is set up. i'm not at all certain about this, but it is a distinct possibility that you and every other client on that machine are all sharing some limited number of connections. on the other hand (and i'm not at all sure about this), linux has capabilities like 'User Mode Linux' and other sorts of things which can make much greater separation between different clients on a host machine. I would ask your hosting provider.

            2) Again, not completely sure but i think a 'daemon' is sort of like a program that runs periodically or as a messenger. They do periodic things like garbage collection and checking for mail and stuff. Checking for certain conditions periodically and initiating appropriate procedures.

            3) I dunno. You could get a dedicated server, but that's pretty expensive. anybody else know?

            4) Try reading the user comments here:
            http://dev.mysql.com/doc/mysql/en/too-many-connections.html

            the first posting i saw was one about showing an alternate page if the database has too many connections. remember that php and mysql are essentially separate applications. the trick involves checking for a particular error condition after you try and connect.

              There's actually a good definition here: daemon

              Basically, before daemons were demonized (haha, get it?) by the Christian religion, they were neither viewed as good nor evil, but as supernatural spirits / beings. This is the meaning assigned to them in unix.

              Most services in Unix run as daemons, hence the rather common last letter of d in things like mysqld or httpd.

                Originally posted by bubblenut

                /me types su and waits for Buffy 😃

                /me stands in line behind bubblenut, waiting for Faith and / or Willow...

                  +++ Back! Back! ye evil spirits! (and vampires, I guess? oh and women who might tempt me away from the path! back I say! +++) :eek:

                  Thanks, guys for the links. Also this def from webopedia.com:

                  daemon

                  Pronounced DEE-mun or DAY-mun. A process that runs in the background and performs a specified operation at predefined times or in response to certain events. The term daemon is a UNIX term, though many other operating systems provide support for daemons, though they're sometimes called other names. Windows, for example, refers to daemons as System Agents and services.

                  Typical daemon processes include print spoolers, e-mail handlers, and other programs that perform administrative tasks for the operating system. The term comes from Greek mythology, where daemons were guardian spirits.

                  I think as far as my original problem I will just have an alternate page on a failed connection plus have that page mail() me a message so I can get on the host to fix it.

                    Originally posted by davidjam
                    I think as far as my original problem I will just have an alternate page on a failed connection plus have that page mail() me a message so I can get on the host to fix it. [/B]

                    Have it email your host instead 😉 :p

                      Write a Reply...