Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Easily solve the MySQL database connection error too many     - Automatic Clear date directory shell script (Linux)

- linux server security (Linux)

- Use mysqldump backup performed MariaDB (Database)

- SQLite database commonly used sentences and visualization tools on MAC MeasSQLlite use (Database)

- Why do I prefer Git (Linux)

- Linux common network tools: batch scanning of nmap hosting service (Linux)

- xCAT deployment (Linux)

- Spring declarative transaction management (Programming)

- Linux console password solution (Programming)

- How Ubuntu Snappy Core 2 running on Raspberry Pi (Linux)

- Linux server dual-card dual-IP and single-card dual-IP configuration method (ReHat / CentOS) (Server)

- How to achieve the MySQL Oracle table associated with the two operations update (Database)

- PostgreSQL 9.4.3 Installation and Configuration under CentOS 6.5 (Database)

- C ++ runtime environment built on CentOS 6.6 and Oracle database connection (Database)

- Linux operating system Start Tutorial: Xmanager Remote Access Linux graphical interface (Linux)

- Zorin OS: Linux novice most personal desktop system should be used (Linux)

- Firewall Configuration Red Hat Enterprise Linux 4 (Linux)

- How to install new fonts on Ubuntu 14.04 and 14.10 (Linux)

- The difference between IPython and Python (Linux)

- Java Annotation Comments (Programming)

 
         
  Easily solve the MySQL database connection error too many
     
  Add Date : 2018-11-21      
         
         
         
  1, MySQL database system to allow the maximum number of connections max_connections. This parameter can be set. If not set, the default is 100. The maximum is 16384.

2, the current database connection threads threads_connected. This is a dynamic change.

View max_connections, max_connections approach see below.

If when threads_connected == max_connections, the database system can not provide more connections, and then, if the program would like to create a new connection threads, the database system will be rejected if the program did not do much error handling, there will be similar strong altar of error messages.

Because creating and destroying database connection resources, will consume system. And in order to avoid too many open simultaneously at the same time the connection thread, now generally use the so-called programming database connection pool technology.

But the database connection pool, and can not avoid procedural errors caused the connection resource depletion.

This usually occurs in the program failed to release the database connection resources or other causes database connection resources can not be released, but it is estimated that this low intensity system altar programming errors do not occur.

Easy way to check the error is in strong altar refresh the page constantly monitors the changes threads_connected. If max_connections large enough, increasing the value and threads_connected even reach max_connections, so, you should check the program. Of course, if the maximum number of threads connecting a database connection pool, threads_connected growth to the database connection pool use, no longer increase.

Strong altar from the situation of error, the more likely is the database system could not be properly configured. Ask the following piece of advice. for reference

Let your engineers to MySQL's maximum allowable number of connections from the default of 100 tune into 32000. This is not the old problem of excessive connected.

View max_connections

Enter MySQL, use the command:

show variables

View database maximum number of connections to the values:

max_connections

View threads_connected

Enter MySQL, use the command:

show status

View the current activity variable values ​​connecting thread:

threads_connected

Setting max_connections

Approach is set in the my.cnf file, add the following last red line:

[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 = 32000

After modification, you can restart the MySQL. Of course, in order to ensure the settings are correct, we should look max_connections.

note:

1, although the writing here 32,000. But the maximum number of connections the actual MySQL server allows 16384;

2, in addition to max_connections, the above-mentioned other configuration should be based on their need to configure your system, not rigidly stick to;

3, add the maximum allowable number of connections to the system consumes little increase.

4, if you use the my.ini for mysql configuration file settings similar, but set the format to make some modifications
     
         
         
         
  More:      
 
- Node.JS different ways to install under Ubuntu 15.04 (Linux)
- Linux user status query, and to unlock locked user (Linux)
- gzip, bzip2, xz, tar, zip compression, archive Detailed (Linux)
- The wrong in Linux: too many open files (Linux)
- Add local search to your Android app (Programming)
- Nginx load balancing configuration (TCP proxy) (Server)
- Git Advanced Tutorial (Linux)
- Linux process scheduling opportunity (Programming)
- MySQL 5.7 perfectly distributed transaction support (Database)
- Oracle 10g in the unique and index problems (Database)
- Using Java to build micro-services (Server)
- How to build a custom exclusive Ubuntu Live CD (Linux)
- Linux disk partition, format, mount the directory (Linux)
- Linux network security backdoor technology and advanced skill practice (Linux)
- 10 Codes of good practice PHP (Programming)
- Detailed driver compiled into the Linux kernel (Programming)
- VirtualBox CentOS is configured as a local disk mirroring software source (Linux)
- Simple to use Linux GPG (Linux)
- Oracle 11g creates virtual private directory RMAN-06004 ORA-00942 error handling (Database)
- Linux environment MySQL master-slave synchronization (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.