mysql 'too many connections' error mysql solution

  • 2020-05-09 19:24:54
  • OfStack

The solution is to modify/etc/mysql/my cnf, add the following line 1:
set-variable = max_connections=500

Or add the parameter max_connections=500 to the startup command
This is to change the maximum number of connections, and then restart mysql. The default number of connections is 100, which is too small, so it is easy to make mistakes.
The mysql.com website explains:
If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.

The number of connections allowed is controlled by the max_connections system variable. Its default value is 100. If you need to support more connections, you should restart mysqld with a larger value for this variable.

mysqld actually max_connections+1 clients to connect. The extra connection reserved accounts accounts have the privilege By SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect the server use SHOW PROCESSLIST even the maximum of unprivileged are connected See Section 13.5.4.19, "SHOW PROCESSLIST Syntax".

The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform. Linux or Solaris should be able to support 500-1000 simultaneous connections, depending on how much RAM you have and what your clients are doing. Static Linux binaries provided by MySQL AB can support up to 4000 connections.

1. It may be the max connections setting of mysql
2. It may be multiple insert,update operation did not turn off session, so transaction support needs to be configured in spring.

Solution:
1. Modify the time-out of session in tomcat to reduce the time to 20 (not required)
2. Provide transaction support for database insert or update operations with large processing capacity.

=======================================
Here's the solution:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"

The reason:

Because your mysql installation directory, my.ini, sets too few concurrent connections or the system is busy, the number of connections is full

Solution:

Open the MYSQL installation directory and open MY.INI and find max_connections (around line 93). The default is 100 1 and it is appropriate to set it to 500 ~ 1000. Restart mysql and the 1040 error will be resolved.
max_connections=1000

MYSQL must be restarted to take effect

CMD- >

net stop mysql

net start mysql

About the problem that mysql cannot be started after changing innodb_log_file_size

innodb_buffer_pool_size=768M
innodb_log_file_size=256M
innodb_log_buffer_size=8M
innodb_additional_mem_pool_size=4M
innodb_flush_log_at_trx_commit=0
innodb_thread_concurrency=20
The above is the preliminary optimization of innodb engine. It was found that there was a problem when updating innodb_log_file_size=256M. As long as adding this, it could not be started.

Only later did I learn that I wanted the STOP service first and then delete the original file...
Open /MySQL Server 5.5/data

Delete ib_logfile0 ib_logfile1... ib_logfilen
Turn on the option again and launch successfully.


Related articles: