How to set the number of mysql connections (Too many connections)

How to set the number of mysql connections (Too many connections)

During the use of mysql, it was found that the number of connections exceeded~~~~

[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p

Enter password:

ERROR 1040 (08004): Too many connections

The solution is to modify the number of mysql connections under centos7:

1) Temporary modification

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 | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)

2) Permanent modification:

Configure /etc/my.cnf
[mysqld] Add a new line with the following parameters:
max_connections=1000
Restart the mariadb service and check the maximum number of connections to the mariadb database again. 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 a default limit on the number of open files. You can increase the number of open files by configuring /usr/lib/systemd/system/mariadb.service.

Configure /usr/lib/systemd/system/mariadb.service

[Service] Add two new lines with the following parameters:
LimitNOFILE=10000
LimitNPROC=10000

Reload system services and restart mariadb service

systemctl --system daemon-reload
systemctl restart mariadb.service

Check the maximum number of connections of the mariadb database again, and you can see that the maximum number of connections is already 1000

MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+

The above article on setting the number of MySQL connections (Too many connections) is all I have to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL "too many connections" error MySQL solution
  • Mysql error: Too many connections solution
  • How to solve MySQL 1040 error Too many connections
  • Mysql error too many connections solution
  • Solution to mysql too many open connections problem
  • Causes and solutions for MySQL too many connections error
  • How to solve the MySQL error "too many connections"

<<:  Code block highlighting can be copied and displayed js plug-in highlight.js + clipboard.js integration

>>:  Nginx server https configuration method example

Recommend

How to automatically start RabbitMq software when centos starts

1. Create a new rabbitmq in the /etc/init.d direc...

The use of setState in React and the use of synchronous and asynchronous

In react, if you modify the state directly using ...

Example code of the spread operator and its application in JavaScript

The spread operator allows an expression to be ex...

Can Docker become the next "Linux"?

The Linux operating system has revolutionized the...

MySQL string splitting example (string extraction without separator)

String extraction without delimiters Question Req...

Solution to MySQL IFNULL judgment problem

Problem: The null type data returned by mybatis d...

Advantages of MySQL covering indexes

A common suggestion is to create indexes for WHER...

Analysis of the difference between HTML relative path and absolute path

HTML beginners often encounter the problem of how ...

Example of implementing circular progress bar in Vue

Data display has always been a demand that all wa...

Example of how to generate random numbers and concatenate strings in MySQL

This article uses an example to describe how MySQ...

JavaScript to implement dynamic digital clock

This article shares the specific code for impleme...