008 A solution to PHP database 1040 too many connections

不言
Release: 2023-03-24 15:44:01
Original
1869 people have browsed it


I wrote a scheduled task to frequently request an interface, and this error occurred. It seemed that too many processes were blocking the database. The first is to stop the scheduled task, then enter the database and enter show processlist; then kill the redundant processes. However, if there are too many processes, it is troublesome to delete them individually. A master has written a shell script to delete these processes in batches, for i in `mysql -uroot -p123 -h127.0.0.1 -e "show processlist"|grep -v 'Id'|awk '{print $1}'`; do mysql -uroot -p12345 -h10.10.14.18 -e "kill $i"; done;

-p is followed by the database password, and -h is followed by your own host. If you want to connect directly, delete the host. This will work too

for i in `mysql -uroot -p123 -e "show processlist"|grep -v 'Id'|awk '{print $1}'`; do mysql -uroot -p12345 -e "kill $i"; done;

that's it.

Related recommendations:

PHP database addition, deletion, modification query

PHP database is based on PDO operation class (mysql)


The above is the detailed content of 008 A solution to PHP database 1040 too many connections. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template