Databases can accumulate a significant number of idle connections that remain open for extended periods. This can lead to resource consumption and performance issues.
One approach is manual termination of idle processes. To identify open connections, use the SHOW FULL PROCESSLIST command. You can then kill the process with KILL [process_id].
However, this method has limitations:
A more comprehensive solution is to configure the MySQL server with shorter timeouts for idle connections. Edit the my.cnf file and adjust the following parameters:
wait_timeout=3 interactive_timeout=3
With these settings, MySQL will automatically terminate idle connections after 3 seconds.
While this approach is effective, it's important to investigate the root cause of idle connections. Issues like PHP connection pooling can contribute to this problem and should be addressed.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3