473,666 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2228


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**@startrekf reedom.com> schreef in bericht
news:42******** *************** @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

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

Cheers,

Anthony

"Wim Roffil" <wimroffel@plea se_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
2588
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 to disk with no missing data). I've recently started do the same thing with database connections. I'm wondering if anyone has had trouble with this sort of "lazy" programming style. My assumption is the the database connection will get closed...
0
3259
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 configuration:
0
2139
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 + replication + windows XP PROF Hi, it's my story.
16
27907
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 own LAN, the driver tells me it cannot make the connection. Here are the ODBC driver connection parms: Data Source Name: (free field - name my "my linux box" will do nicely) Host/Server Name (or IP) - something like MSQLUserName@ServerName.net...
1
2206
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 logged into phpmyadmin it said: Error
7
1797
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
3371
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 uses his own php shopping cart to receive customer orders. The configuration was done via cPanel with no external modifications - which produced no protests when built, ran and connected with no
7
3248
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 am trying to develop a photoalbum (also posted a topic called "array / mysql question"). Of course I can use some wonderful open source albums but at the same time I want to get more familiar with all the ins and outs so my idea is a list of...
1
3034
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 wrote my ColdFusion code in Dreamweaver and just assumed it would take care of issues like this, but I guess it doesn't. If I have a few windows open on the same machine and just keep hitting the site, I can easily cause it to 'crash' to the point...
0
8363
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8787
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.