MySQL ERROR 1040:too many connections

Source: Internet
Author: User
Tags mysql in


The wrong hint is as follows

#/home/binbin.zhengbb/ssh/update_dns.sh

ERROR 1040 (08004): Too Many connections

ERROR 1040 (08004): Too Many connections

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.
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:

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.

Method One: Directly modify MySQL

The code is as follows Copy Code

Mysql> Show variables;

| max_connections | 100

Mysql> set GLOBAL max_connections=1500;

Method Two: Modify the configuration file

  code is as follows copy code
[Intranet Root@inc-dp-149-47/root]

#vi/etc/my.cnf

 

[Mysqld]

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

# Default to using old password format for compatibility with MySQL 3.x

# clients (those using the Mysqlclient10 compatibility package).

Old_passwords=1

Log-bin=/var/lib/mysql/mysql_bin_log/log-bin

Expire_logs_days=7

Log-slow-queries=/var/log/mysqld_slow_query.log

Set-variable=max_connections=1500

 

[Mysqld_safe]

Log-error=/var/log/mysqld.log

#log-update=/var/log/mysqld_update.log

Pid-file=/var/run/mysqld/mysqld.pid

The final reboot of our MySQL database server is OK.

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.