Maximum number of connections to MySQL database
Background knowledge:
MySQL maximum number of connections default value is 100, for a large number of concurrent connections database, when the connection request is greater than the default number of connections, there will be an error can not connect to the database, so we need to increase it appropriately, when using MySQL database, often encounter such a problem, that is,"Can not connect to MySQL server." Too many connections"-mysql 1040 error, this is because the number of unreleased connections accessing MySQL has reached MySQL's limit. Usually, the maximum number of connections for mysql defaults to 100, and the maximum number can reach 16384.
MySQL Maximum number of connections View and modify
1. View the maximum number of connections after logging into the database
show variables like '%max_connections%';
2. Modify the maximum number of connections
set GLOBAL max_connections = 200;
Note: Using this method to modify the maximum number of database connections can only take effect in the current mysql service process. Once mysql restarts, it will return to the initial state. Because mysql needs to read the data in the/etc/my.cnf configuration file during initialization and startup, it is recommended to write the parameter max_connections in the mysql configuration file/etc/my.cnf.