Home >Database >Mysql Tutorial >What should I do if mysql database prompts that there are too many connections?
Solution to the problem that mysql database prompts that there are too many connections: 1. Log in to the mysql database and view the currently active connection thread variable values; 2. Edit the my.cnf configuration file and add [[mysqld] port=3306]; 3. Restart the mysql server.
Solution:
View max_connections
(Recommended tutorial: mysql video tutorial)
Enter MySQL, use the command:
$ show variables
View the variable value of the maximum number of connections to the database: max_connections
View threads_connected
Enter MySQL, use the command:
$ show status
View the currently active connection thread variable value: threads_connected
Set max_connections, in the my.cnf file, add the following last line:
Copy
[mysqld] port=3306 #socket=MySQL ...set-variable = max_connections=32000
After the modification is completed, restart MySQL. Of course, to make sure the settings are correct, you should look at max_connections.
Note:
1. Although 32000 is written here. However, the actual maximum number of connections allowed by the MySQL server is 16384;
2. In addition to max_connections, the other configurations mentioned above should be configured according to the needs of your system without being rigid;
3. The maximum allowed number is added The number of connections does not increase system consumption much.
4. If your mysql uses my.ini as the configuration file, the settings are similar, but the format should be slightly modified
Related recommendations: mysql tutorial
The above is the detailed content of What should I do if mysql database prompts that there are too many connections?. For more information, please follow other related articles on the PHP Chinese website!