Database Too many connections workaround

Source: Internet
Author: User

Problem: The website suddenly error, show "Too many connections ..." What is this?

Solve:

A few useful actions are listed first:

  ① mysql -u root -pEnter the password into MySQL

show processlist; View the number of connections, you can find that there are many connections in sleep state, these are actually temporarily useless, so you can kill

  ③ show variables like "max_connections";View the maximum number of connections, which should be the same as the number of connections queried above, before too many connections is present

  ④ set GLOBAL max_connections=1000;Modify the maximum number of connections, but this is not a once and for all method, you should let it automatically kill those sleep processes.

  ⑤ show global variables like ‘wait_timeout‘;This value refers to the number of seconds that MySQL waits before closing a non-interactive connection, which defaults to 28800s

   ⑥ set global wait_timeout=300; Modify this value, here can be arbitrary, preferably control in a few minutes

   ⑦ set global interactive_timeout=500; Modify this value to indicate the number of seconds that MySQL waits before closing a connection, so that MySQL automatically shuts down those useless connections, but be aware that the connection that is being used is also turned off , so this time value should be appropriate

My workaround:

select concat(‘KILL ‘,id,‘;‘) from information_schema.processlist where user=‘root‘; First query the connection ID to kill

② Copy the middle of thekill id; 

Copy the modified content back to the terminal, and then press ENTER to execute

Database Too many connections workaround

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.