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.