|
Home > Archive > MySQL Server Forum > June 2005 > Closing MySQL Connections
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Closing MySQL Connections
|
|
| Anthony 2005-06-06, 3:23 am |
| Hey all,
Here's a question for you, my hosts have told me that that one my pages,
php, was causing their server to reboot because there were too many open
connections and that they should be closed.
Now, correct me if I am wrong but I thought that the connections were closed
after a minute of inactivity.
Does this sound right? Could open connections cause their server to reboot a
lot, say 3 times in 15 minutes? If so, what can I do about it?
Any insight is welcome,
Anthony
| |
| andreas.maurer1971@web.de 2005-06-06, 7:23 am |
|
Anthony schrieb:
> Hey all,
>
> Here's a question for you, my hosts have told me that that one my pages,
> php, was causing their server to reboot because there were too many open
> connections and that they should be closed.
>
> Now, correct me if I am wrong but I thought that the connections were closed
> after a minute of inactivity.
>
> Does this sound right? Could open connections cause their server to reboot a
> lot, say 3 times in 15 minutes? If so, what can I do about it?
>
> Any insight is welcome,
>
> Anthony
Hi Anthony,
usually you always should issue the statement mysql_close() at the end
of each php- page. This closes the mysql connection that got opened
during the script.
In case you use the command mysql_pconnect() to connect to MySQL you
must(!!) use mysql_close() at the end as otherwise your connections
will be left open for x amount of time. How long should be defined
somewhere in the ini-files of MySQL but I'm not sure where.
Otherwise and recommended practice is the command mysql_connect() as a
means to connect to MySQL as at the end of the script the recently
opened connection gets closed automatically and no mysql_close() is
needed but, of course, still should be issued.
To answer your question whether it is possible that too many open
connections can cause a server to reboot I can't give you any input but
to me this sounds logical. Of course the definition of "how many is too
many" depends on many different things and the question how often a
reboot might be required depends on the amount of traffic you have on
your website. A lot of traffic = a lot of open connections => server
reboots sooner ;-)
HTH,
Andy
| |
| Wim Roffil 2005-06-06, 11:23 am |
| Since updating to Mysql 4.1 I see the same problem: my connections are not
anymore automaticaly closed when the PHP program ends. Every time when I
restart my computer and run a MYISAMCHK I get warnings of open connections.
I am afraid that I will have to become religious in closing all connections
before the PHP script ends (and pray that after that it will work).
MySql 4.1: New: yes Improved: ????
Wim
"Anthony" < news@startrekfreedom
.com> schreef in bericht
news:42a40c7d$0$1030
4$afc38c87@news.optusnet.com.au...
> Hey all,
>
> Here's a question for you, my hosts have told me that that one my pages,
> php, was causing their server to reboot because there were too many open
> connections and that they should be closed.
>
> Now, correct me if I am wrong but I thought that the connections were
closed
> after a minute of inactivity.
>
> Does this sound right? Could open connections cause their server to reboot
a
> lot, say 3 times in 15 minutes? If so, what can I do about it?
>
> Any insight is welcome,
>
> Anthony
>
>
| |
| Anthony 2005-06-06, 8:23 pm |
| Okay, thanks Wim, looks like I have a few mysql_close($connect
ion) commands
to add to my code.
Cheers,
Anthony
"Wim Roffil" < wimroffel@please_no_
spam-planet.nl> wrote in message
news:d81s72$ive$1@re
ader11.wxs.nl...
> Since updating to Mysql 4.1 I see the same problem: my connections are not
> anymore automaticaly closed when the PHP program ends. Every time when I
> restart my computer and run a MYISAMCHK I get warnings of open
> connections.
>
> I am afraid that I will have to become religious in closing all
> connections
> before the PHP script ends (and pray that after that it will work).
>
> MySql 4.1: New: yes Improved: ????
>
> Wim
>
|
|
|
|
|