473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Closing MySQL Connections

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
Jul 23 '05 #1
3 2213


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

Jul 23 '05 #2
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" <ne**@startrekfreedom.com> schreef in bericht
news:42***********************@news.optusnet.com.a u...
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

Jul 23 '05 #3
Okay, thanks Wim, looks like I have a few mysql_close($connection) commands
to add to my code.

Cheers,

Anthony

"Wim Roffil" <wimroffel@please_no_spam-planet.nl> wrote in message
news:d8**********@reader11.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

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written...
0
by: I.P. | last post by:
Hi, it's my story. I have two 4.0.14 mysql server on one machine with win XP Professional polish version. First acts as master: on port 3300 Second acts as slave: on port 3301 below my...
0
by: I.P. | last post by:
No one has replied to my post. ----- Original Message ----- From: "I.P." <jancio_wodnik@wp.pl> To: <mysql@lists.mysql.com> Sent: Monday, August 18, 2003 1:01 PM Subject: mysql 4.0.14 +...
16
by: MLH | last post by:
Using MS Access, I have attached to MySQL servers in other states and other countries on the other side of my router. But when I use the MySQL ODBC driver 3.51 to connect to a MySQL server on my...
1
by: Gregory.Spencer | last post by:
Hi There, Been working in a PHP / MySQL project I took over code development for. Today when testing new changes suddenly started getting "Failed to connect to the database" errors. When...
7
by: Tumurbaatar S. | last post by:
Is it so important to close database connections? As I understand, after processing a request and sending a response, page object destroyed. So all used connections also destroyed. Yes?
1
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
1
by: lee2732 | last post by:
I am running a website at GoDaddy where I have their least expensive plan that supports Linux/ColdFusion/mySQL. Apparently this plan supports a small number of active database connections (50). I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.