How to solve the problem of too connector connections in MySQL

Source: Internet
Author: User

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.

Related Article

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.