MySQl modifies the maximum number of connections

Source: Internet
Author: User

Today using the IDE connection line under MySQL error can not connect to MySQL server. Too many connections, the error is clear, the connection with MySQL is full. Also, each service creates a MySQL connection pool, which takes up a lot of long connections. With the IDE to see a bit, the original maximum number of connections only 151, it seems necessary to change a bit.

Check the Internet, there are two ways to modify

1. Command-line modification

after entering MySQL, set GLOBAL max_connections=1024; can take effect immediately, but bloggers do not use this approach, because this method is not a cure, a little restart MySQL, the maximum number of connections will change back to 151

2. Modify the configuration and restart

VI/ETC/M.CNF Add max_connections=1024, then restart MySQL.

After restarting, unfortunately, Max_connections became 214, which is very strange. I set the max_connections to 500 and 213 respectively, and the actual max_connections were 214 and 213 respectively. That is, on this server, max_connections maximum can only be 234, guess is because the operating system limits cause max_connections maximum can only be 213. Bloggers turned over the official MySQL document (English is not good to read the document is very uncomfortable), found the following words:

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the Amount of RAM available, how much ram are used for each connection, the workload from each connection, and the desired RESP Onse time. Increasing open-files-limit may necessary. Also See section 2.5, ' Installing MySQL on Linux ', for what to raise the operating system limit in how many handles can is Used by MySQL.

In my English level, the above statement summed up is that Max_connections relies on the operating system, the Linux system need to increase the open-files-limit. Never thought Ah, modify max_connections unexpectedly to modify the operating system maximum file descriptor.

Vi/usr/lib/systemd/system/mysqld.service Join

limitnofile=50000

Restart MySQL

Yes, it's done.

I hope you have some help, I wish you every day happy ~

MySQl modifies the maximum number of connections

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.