ERROR 1040:too Many connections problem solving method

Source: Internet
Author: User
Tags mysql in

The reason for this error is that the amount of traffic is really high, the MySQL server will not hold, this time to consider increasing the read pressure from the server spread, the other is the MySQL configuration file max_connections value is too small.

Analyze the reason

MySQL's default connection is only 100, that is, the connection data over 100 will likely appear Too Many connections

Modify MY.CNF profile Add and reboot required:

[Mysqld]

Wait_timeout = 600
Interactive_timeout = 600

Query the maximum number of MySQL connections:

The code is as follows Copy Code

Mysql> Show variables like ' max_connections ';
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| max_connections | 100 |
+-----------------+-------+
1 row in Set (0.00 sec)

Maximum number of connections to query MySQL response:

The code is as follows Copy Code

Mysql> show global status like ' Max_used_connections ';
+----------------------+-------+
| variable_name | Value |
+----------------------+-------+
| max_used_connections | 5 |
+----------------------+-------+
1 row in Set (0.00 sec)

Description: The local environment is not a reference value, but in the above data, MySQL in the past to respond to the maximum number of connections is less than the maximum number of connections allowed, so there will be no 1040 errors.
MySQL is ideal for the maximum number of connections calculated by:

The code is as follows Copy Code

Max_used_connections/max_connections * 100%≈85%

That is, the maximum number of connections to the upper limit of 85% of the number of connections, if the ratio is found below 10%, MySQL server connection number of the upper limit set too high.


problem to find a solution

1, Mysql-u root-p can not enter, the same error occurred.

2, modify/ETC/MYSQL/MY.CNF (Ubuntu system, other systems in/ETC/MY.CNF

The code is as follows Copy Code

[Mysqld]
port=3306
#socket =mysql
Skip-locking
Set-variable = key_buffer=16k
Set-variable = max_allowed_packet=1m
Set-variable = thread_stack=64k
Set-variable = table_cache=4
Set-variable = sort_buffer=64k
Set-variable = net_buffer_length=2k
Set-variable = max_connections=1000

3, restart

The code is as follows Copy Code

Mysql/etc/init.d/mysql restart

It's done.

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.