girish.kc Posted December 28, 2011 Share Posted December 28, 2011 Hi I am using a php class to connect to the MySQL database, which uses the following code snippet. /* establish connection, select database */ if (0 == $this->Link_ID) { $this->Link_ID = mysql_pconnect($Host, $User, $Password); if (!$this->Link_ID) { $this->halt("pconnect($Host, $User, \$Password) failed."); return 0; } } if (!@mysql_select_db($Database, $this->Link_ID)) { $this->halt("cannot use database " . $this->Database); return 0; } Now I'm facing the mysql idle connections problem. The number of idle connection is growing rapidly even the max_used_connection is very less. I tried to set the variable wait_timeout and interactive_timeout to as low as 5. But there is no improvement. Need some help. Girish Quote Link to comment https://forums.phpfreaks.com/topic/253944-lot-of-idle-connections-in-mysql/ Share on other sites More sharing options...
trq Posted December 28, 2011 Share Posted December 28, 2011 Do you understand how mysql_pconnect() works? Quote Link to comment https://forums.phpfreaks.com/topic/253944-lot-of-idle-connections-in-mysql/#findComment-1301826 Share on other sites More sharing options...
girish.kc Posted December 28, 2011 Author Share Posted December 28, 2011 Sorry.. By mistake I posted the wrong code. Yes I know how mysql_pconnect() works. I am not using _pconnect.. I was just testing with it. Here is the actual code I'm using: /* establish connection, select database */ if (0 == $this->Link_ID) { $this->Link_ID = mysql_connect($Host, $User, $Password); if (!$this->Link_ID) { $this->halt("connect($Host, $User, \$Password) failed."); return 0; } } if (!@mysql_select_db($Database, $this->Link_ID)) { $this->halt("cannot use database " . $this->Database); return 0; } Quote Link to comment https://forums.phpfreaks.com/topic/253944-lot-of-idle-connections-in-mysql/#findComment-1301827 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.