Solution to the increase in the number of mysql connections in case of unrecoverable Question
Question:
The mysql connection of the company's website exceeds the limit, and the website basically cannot be moved. after analyzing the traffic, it is not caused by traffic surge or hacker attacks.
Analysis:
Log on to the mysql server and perform the following checks:
1. use show processlist to view the threads being executed by mysql. A large number of sleep and timeout threads are found.
2. kill all sleep or timeout threads. However, the number of connections immediately increases. Observe the SQL statements executed by some timeout connections, and find that there are many query timeouts related to its user table.
3. use check table user to find that the table is damaged. After the repair table user is used to repair the table, it does not improve. No way, you have to dump the table mysqldump and then import it in source mode. After observing the number of connections, we found that we have recovered to the normal level. Well, haha.
Summary:
1. the database is the same as the car, and maintenance is often required. Myisamchk, check table, and optimize table can all be used, especially optimize, which is very important for tables with large numbers of updated and long rows.
2. if you are not familiar with mysql status monitoring commands, you can use the official mysql adminiistrator GUI tool to clearly view the mysql running status.
BitsCN.com