Close The Connection

If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.

always make sure you close the connection of the database by mysql_close() and in the mysql_connect() set new_link to false and set client_flags to MYSQL_CLIENT_INTERACTIVE flag (it will use the MySQL interactive_timeout value instead of wait_timeout) for limiting the number of connection and limiting the connection timeout and don’t forget to maximize the number of connection by setting MySQL max_connections variable to the number you think its better to your web server (the default in MySQL 5.1.15 is 151, previously, the default was 100 but most servers dose not use MySQL 5.1.15 yet ) if you really want to know how i’ll tell you later about how much servers can handle.

Since wait_timeout defaults to 8 hours. However, surprisingly, interactive_timeout also defaults to 8 hours. You should change this value to something smaller that fits your system.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.