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

Detailed explanation of Linux Namespace User

User namespace is a new namespace added in Linux ...

Vue3 (III) Website Homepage Layout Development

Table of contents 1. Introduction 2. Actual Cases...

How to delete garbled or special character files in Linux

Due to encoding reasons, garbled characters will ...

vue+rem custom carousel effect

The implementation of custom carousel chart using...

How to configure wordpress with nginx

Before, I had built WordPress myself, but at that...

Detailed explanation on reasonable settings of MySQL sql_mode

Reasonable setting of MySQL sql_mode sql_mode is ...

Detailed explanation of eight methods to achieve CSS page bottom fixed

When we are writing a page, we often encounter a ...

Hexadecimal color codes (full)

Red and pink, and their hexadecimal codes. #99003...

VMware Tools installation and configuration tutorial for Ubuntu

Some time ago, the blogger installed the Ubuntu s...

Use Docker to run multiple PHP versions on the server

PHP7 has been out for quite some time, and it is ...

How to upgrade MySQL 5.6 to 5.7 under Windows

Written in front There are two ways to upgrade My...

Two-hour introductory Docker tutorial

Table of contents 1.0 Introduction 2.0 Docker Ins...

vue cli3 implements the steps of packaging by environment

The vue project built with cli3 is known as a zer...

How to migrate local mysql to server database

We can use the scp command of Linux (scp cannot b...

Docker batch start and close all containers

In Docker Start all container commands docker sta...