Mysql "toomanyconnections" failed to connect to the database ..

Source: Internet
Author: User
This afternoon, the website continued to encounter database connection failures. It would be better to restart mysql, but after a while, the database connection failure may occur. Check monitorix and find an exception. Ask tech experts for help. The first time you encounter such a problem, GoogleAnalytics displays...

This afternoon, the website continued to encounter database connection failures. It would be better to restart mysql, but after a while, the database connection failure may occur.

Check monitorix and find an exception. Ask tech experts for help. If you encounter such a problem for the first time, GoogleAnalytics shows that the real-time traffic is about 100, which is not normal.

Please advise!

Reply content:

This afternoon, the website continued to encounter database connection failures. It would be better to restart mysql, but after a while, the database connection failure may occur.

Check monitorix and find an exception. Ask tech experts for help. If you encounter such a problem for the first time, GoogleAnalytics shows that the real-time traffic is about 100, which is not normal.

Please advise!

If your PHP uses persistent connections to access MySQL (A PHP-FPM process keeps a MySQL persistent connection, eliminating the overhead of repeatedly establishing a connection each request), then the number of PHP-FPM processes pm. max_children should not exceed the maximum number of connections of MySQL max_connections (151 by default ). if you are using Apache, the number of httpd processes should not be more than the maximum number of connections of MySQL.

Some queries may encounter performance problems as data increases, resulting in many SQL statements being blocked. You can run the following command to view the current SQL statement.

show full processlist;

In addition, you can enable MySQL slow query logs to record time-consuming queries and then optimize them.

Another case is that the hard disk is full.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.