0

I've built a website and has been running for a while now. but suddenly today I received and error that the maximum connections to the DB is reached.

how can I list the open connections and terminate them using PHP order even through the Db manegement server

sikas
  • 5,435
  • 28
  • 75
  • 120
  • [Not a real answer but maybe helpful...](http://www.microshell.com/database/mysql/mysql-too-many-connection-errors/) – xQbert Apr 15 '12 at 19:28

3 Answers3

0

This problem happens because you have a lot of users opening connections at the same time. Also, Ajax can cause this problem. Once the execution of the page is done, the connection should of been terminated. Make sure you are recycling a single connection per user every time the page opens when you try different things. For instance you do not want to reopen a connection to the DB (passing user and pass) every time you execute a DB query. Open it once and keep using it until the page renders. It could be that your connections are not being terminated properly but I have not run into this problem before; I do know that PHP has the potential to miss manage connections. Contact your host and ask how many connections are allowed to the DB at any one moment and if they can increase it.

Serguei Fedorov
  • 7,763
  • 9
  • 63
  • 94
0

Just every time after executing query close(); connection.

mysql_close ([ resource $link_identifier = NULL ] );

mysqli::close ( void );

mysqli_close ( mysqli $link );
dr.dimitru
  • 2,645
  • 1
  • 27
  • 36
0

The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP interpreter is created and destroyed for every page request (for a PHP page) to your web server. Because it is destroyed after every request, any resources that it acquires.

  • You mentioned "The first method" is there another method? Also the sentance, "Because it is destroyed after every request, any resources that it acquires." seems open ended and doesn't look like it answers the original question, could you clarify please? – Matthew Jul 04 '19 at 09:04