Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/253944-lot-of-idle-connections-in-mysql/
Share on other sites

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;
        }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.