MySQL connection too many connection error and very long boot time

Source: Internet
Author: User

Yesterday a server on a strange problem, normal access when the MySQL appears "error 1040, too many connection" error prompts, which is usually max_connections set too small or wait_ The timeout value setting is too long to cause the connection timeout to be too long. So the first thing to think of is using mysqladmin to see how much the Max_connections value is.

This problem arises because:

The number of connections exceeds the value set by MySQL and is related to both max_connections and wait_timeout. The larger the value of the wait_timeout, the longer the idle wait for the connection, which causes the current number of connections to become larger.

Workaround:

The code is as follows Copy Code

1.[root@localhost bin]$./mysqladmin-uroot-p Variables | grep "Max_conn"

After you enter the password for the database, you can see the value of the max_connections, if too small (the default is 100) you need to set the value larger. If MySQL does not allow interruption, you can login to MySQL, and then set the current max_connections value

The code is as follows Copy Code

1.[root@localhost bin]$./mysql-uroot-p
2.mysql> set GLOBAL max_connections=1024;


It also needs to be noted that Linux if the system max user processes below Max_connections value will appear "can" t create a new thread (errno 11); "Error, the workaround can refer to MySQL appearing can ' t create a new thread (errno 11); Solution. The above settings are valid only in the current state of operation, if the MySQL reboot after the setting expires, so the ultimate method is to modify the MySQL configuration file my.cnf, and then under [Mysqld] set the max_connections value.

But strangely enough, the error still occurs after you log on to MySQL and use show processlist to view the connection and then use the KILL command to delete some sleep-state connections, but later too many Connection the error message. In addition I also noticed a phenomenon, that is, MySQL startup or restart time is particularly long, the database has about 2G of data, but also not start so slow? It was later thought that there was a problem with the database file, and then the repair command was used to fix each table, but the above error would still occur after two hours.

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.