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