MySQL Connection number setup operation (Too many connections)

Source: Internet
Author: User

MySQL in the process of use, found that the number of connections over ~ ~ ~

[Email protected] ~]# mysql-u glance-h 192.168.1.17-p
Enter Password:
ERROR 1040 (08004): Too Many connections

Workaround, which is also the practice of modifying the number of MySQL connections under Centos7:
1) temporarily modify
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in Set (0.00 sec)
MariaDB [(None)]> set GLOBAL Max_connections=1000; 
Query OK, 0 rows Affected (0.00 sec)
MariaDB [(none)]> show variables like "Max_connections";
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| max_connections | | |
+-----------------+-------+
1 row in Set (0.00 sec)

2) Permanent modification:
Configure/ETC/MY.CNF
[Mysqld] Adds a new line with the following parameters:
max_connections=1000
Restart the MARIADB service to see the maximum number of connections for the MARIADB database again, and you can see that the maximum number of connections is 214, not the 1000 we set.
MariaDB [(None)]> show variables like ' max_connections ';
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
This is because MARIADB has the default number of open files limit. You can adjust the number of open files by configuring/usr/lib/systemd/system/mariadb.service.

Configure/usr/lib/systemd/system/mariadb.service
Add two new lines with the following parameters:
limitnofile=10000
limitnproc=10000

Reload the system service and restart the MARIADB service
Systemctl--system daemon-reload
Systemctl Restart Mariadb.service

To see the maximum number of connections for the MARIADB database again, you can see that the maximum number of connections is 1000
MariaDB [(None)]> show variables like ' max_connections ';
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+

MySQL Connection number setup operation (Too many connections)

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.