MySQL database too connector connections
This error is obviously because mysql_connect is forgotten after mysql_close;
After a large number of connections, the too connector connections error will occur. The default MySQL connection is 100. Under what circumstances will this error occur?
Call mysql_close () to close the connection after mysql_connect is normal.
However, when a connection error occurs, mysql_real_query () may forget mysql_close ();
ThereforeProgramBefore return, you must determine whether to close (). The safest way is to have only one exit when writing any function!
You can also modify the MySQL configuration file to increase the number of connections allowed!
Sometimes, this error often occurs on your server:
The error message is as follows:
Can not connect to MySQL Server
Error: Too internal connections
Errno.: 1040
Similar Error Report has beed dispatched to administrator before.
from the official documentation know that the MySQL compiled and installed on Linux defaults to 100 connections
documentation: http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
MySQL officially told us that we need to modify the value of max_connections. How can we modify it? There are two methods
1. modify the configuration file
Modify/etc/My. the CNF file is added to max_connections = N in [mysqld]. If you do not have this file, copy the file you need from the support-Files folder in the compilation source code *. the CNF file is/etc/My. CNF. I'm using a my-medium.cnf with medium-sized server configuration. For example, the content of my [mysqld] is as follows:
[Mysqld]
Port = 3306
Socket =/tmp/MySQL. Sock
Skip-locking
Key_buffer = 160 m
Max_allowed_packet = 1 m
Table_cache = 64
Sort_buffer_size = 512 K
Net_buffer_length = 8 K
Read_buffer_size = 256 K
Read_rnd_buffer_size = 512 K
Myisam_sort_buffer_size = 8 m
Max_connections = 1000
Because I am not familiar with MySQL, many parameters have not been modified. Haha ..
2. users who do not use the mysqld script to start automatically.
Modify the $ mysql_home/bin/mysqld_safe File
Example:/usr/local/MySQL/bin/mysqld_safe File
Grep-N 'max _ connection' $ mysql_home/bin/mysqld_safe
Modify the max_connections parameter value of the corresponding row number.