I see a lot of connections are open and remain idle for a long time, say 5 minutes.
Is there any solution to terminate / close it from server without restarting the mysql service?
I am maintaining a legacy PHP system and can not close the connections those are established to execute the query.
Should I reduce the timeout values in my.cnf file those defaults to 8 hours?
# default 28800 seconds
interactive_timeout=60
wait_timeout=60
I don't see any problem, unless you are not managing them using a connection pool.
If you use connection pool, these connections are re-used instead of initiating new connections. so basically, leaving open connections and re-use them it is less problematic than re-creating them each time.
Manual cleanup:
You can KILL the processid.
But:
Automatic cleaner service ;)
Or you configure your mysql-server by setting a shorter timeout on
wait_timeout
andinteractive_timeout
Set with:
(and also set in your configuration file, for when your server restarts)
But you're treating the symptoms instead of the underlying cause - why are the connections open? If the PHP script finished, shouldn't they close? Make sure your webserver is not using connection pooling...