Data source rejected establishment of connection, message from server: & quot; Too connector connections & quot;

Source: Internet
Author: User

These days, I have been working on big jobs in project management. web programs often encounter this problem, but it will be fine again later. At first I suspected that the session was not closed, but then I checked the code, the main cause is the database configuration.

Exception information:Data source rejected establishment of connection, message from server: "Too many connections"


Possible causes

1. The max_connections attribute configuration of mysql is too small.
2. Multiple insert operations may be performed, and the update operation does not close the session.


Solution:
1. Reduce the wait_timeout time of the session in tomcat to 200
2. Provides transaction support for database insert or update operations with large processing capacity. (configured in Spring)

Cause:

The number of concurrent connections set in my. ini (linux: my. cnf) in the mysql installation directory is too small or the system is busy, resulting in the full number of connections


Solution:

Windows: Find the mysql installation directory, open the my. ini file, and findMax_connectionsConfiguration,The default value is 100, and the value is set to 1000., Restart mysql

MYSQL must be restarted to take effect.

Run the command in cmd.

Net stop mysql

Net start mysql

 

Linux: Find the mysql installation directory and open the my. cnf file.

 

Add the following three lines under [mysqld ]:


Max_connections = 1000
Max_user_connection= 500

Wait_timeout = 200

 

// Set max_connections to 1000

// Set max_user_connections to 500
// Wait_timeout indicates that the IDLE (IDLE) connection will be closed after 200 seconds, but it will not affect the working connection.

// Save and exit, and restart MySQL

Sudo stop mysql

Sudo start mysql


// Restart MySQL and run the following command to check whether the modification is successful.

# Mysqladmin-uroot-p variables

Password:

// The following information indicates that the modification is successful.

| Max_connections | 1000

| Max_user_connections | 500

| Wait_timeout | 200

 


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.