On Thu, 17 Jul 2003, Eben Goodman wrote: > This comment confuses me: > I have seem some sites code that actually open multiple connections to the > same database..
I have worked on some larger sites that 30+ past and current developers worked on.. Some good, some terrible.. The code typically starts up 1 database connection and all scripts should use it.. (Correct way) This code had programmers using things like DBLibraries, DBIMPTOOL, PHPLIB Database objects, etc.. to make more connections for their scripts/includes.. Scenario: 1) script starts - 1 connection opened for duration (this should be it!) 2) does some work 3) script gets included that different programmer wrote, they use DBLibrary object/etc to establish connection to database (current connections = 2) 4) the madness continues I've see as many as unique 5 connections to a DB to build 1 output page.. This is not good and required much cleanup.. But it is known to happen on larger codebases with many wacky developers > If I am using php's mysql_connect() function, then every time a query is > run this function gets run. Wouldn't this mean that for every query a > new "connection" is opened to the same database? No mysql_connect opens a handle (connection) .. and all subsequent queries using mysql_query are routed thru it.. > [EMAIL PROTECTED] wrote: > > >Suggestion.. make a small script called closeall.php .. basically it has > >some code to force closed the mysql connection opened (be sure to run a > >close for all openened handles) > > > >I have seem some sites code that actually open multiple connections to the > >same database.. > > > >Add this file into php.ini under the script_prepend part (gets run after > >all other scripts are done) .. Perhaps something is getting left open/not > >closing properly? > > > > > > > >On Thu, 17 Jul 2003, Eben Goodman wrote: > > > > > > > >>I run a site that gets a fair amount of traffic throughout the day. For > >>days at a time the site runs smoothly, and then, at seemingly random > >>intervals I get the mysql error "Too many connections". The only > >>solution for this is to stop the mysql service and restart it. I > >>changed the max_connections variable to allow for 300 connections > >>instead of the default 100. When I view processes when the error occurs > >>the process list is totally flooded with mysql processes. > >> > >>I am using php to establish connections and using the mysql_connect() > >>function, not mysql_pconnect. I used to use the pconnect function and > >>it seemed to produce the Too many connections error more frequently. > >> I'm at a bit of a loss with this, any tips on how to address this are > >>greatly appreciated. > >> > >>thanks, > >> > >>Eben > >> > >> > >>-- > >>MySQL General Mailing List > >>For list archives: http://lists.mysql.com/mysql > >>To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > >> > >> > >> > > > > > > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]