mysql error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

mysql error

Post by itsmani1 »

hay when i try to connect with mysql_connect gets following error.
any solution. It was working fine yesterday but now giving error.

Error:
Too many connections
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Can you please tell me what does this mean:
I think it mean available mysql connecitons = 1000
I am not sure if i am right or not?

Max Requests Per Child: 4000 - Keep Alive: off - Max Per Connection: 1000


thank you
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

No, that's with regards to max connections to PHP and does not affect MySQL in any way.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

RAM is of 1 GB so i think it should not affect it.
what's the proper way to close the mysql connection?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:mysql_close()
I am doing something like this:

connection.php

Code: Select all

$link = mysql_connect("localhost","root","pass") or die(mysql_error());
	mysql_select_db("ticket_chest",$link);
test.php

Code: Select all

include "connection.php";
        $qr = "my query";
	$res = mysql_query($qr) or die(mysql_error());
	while($row = mysql_fetch_array($res))
	{
                  // Fetching values
	}

	mysql_close($link);
here is get

too many connections
and when i restart the server it starts working fine.
and then after 20 hours i get this error again.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I can only guess that something or someone else is using up the connections pool. It may be a good idea to turn on logging.

Take a look here: http://dev.mysql.com/doc/refman/5.0/en/log-files.html
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:I can only guess that something or someone else is using up the connections pool. It may be a good idea to turn on logging.

Take a look here: http://dev.mysql.com/doc/refman/5.0/en/log-files.html
can i solve it by making a new mysql user on database? will it work?
as you mentioned that may be someone esle is using this connection pool

I am using mysql 4.1.x
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

itsmani1 wrote:can i solve it by making a new mysql user on database? will it work?
Hmm.. I don't think so, but since I've not run into this issue myself, I can't say with authority.
itsmani1 wrote:I am using mysql 4.1.x
http://dev.mysql.com/doc/refman/4.1/en/log-files.html :)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:
itsmani1 wrote:can i solve it by making a new mysql user on database? will it work?
Hmm.. I don't think so, but since I've not run into this issue myself, I can't say with authority.
itsmani1 wrote:I am using mysql 4.1.x
http://dev.mysql.com/doc/refman/4.1/en/log-files.html :)

thank you,
some one suggested me to go for: mysql_pconnect()
will it make difference?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

itsmani1 wrote:some one suggested me to go for: mysql_pconnect()
will it make difference?
It may, but will probably make it worse. You only need to type one character to try it so let us know. However, without knowing what the problems you will never really have a solution.
(#10850)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

arborint wrote:
itsmani1 wrote:some one suggested me to go for: mysql_pconnect()
will it make difference?
It may, but will probably make it worse. You only need to type one character to try it so let us know. However, without knowing what the problems you will never really have a solution.
yes it has made it worse.
this is the error:
#1040 - Too many connections


One more thing: how can i find total available connections?
and
how can i find consumed connections and free connections?

I tried :

Code: Select all

mysql_stat($link)
and got

Uptime: 12075
Threads: 54
Questions: 638
Slow queries: 0
Opens: 20
Flush tables: 1
Open tables: 14
Queries per second avg: 0.053

thank you
Post Reply