How to set the number of mysql connections (Too connections) and mysqlconnections
When using mysql, it is found that the number of connections has exceeded ~~~~
[Root @ linux-node1 ~] # Mysql-u glance-h 192.168.1.17-p
Enter password:
ERROR 1040 (08004): Too connector connections
Solution: this is also the practice of modifying 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 of the mariadb database again. The maximum number of connections is 214, not 1000.
MariaDB [(none)]> show variables like 'max _ connections ';
+ ----------------- + ------- +
| Variable_name | Value |
+ ----------------- + ------- +
| Max_connections | 214 |
+ ----------------- + ------- +
This is because mariadb has the default limit on the number of opened files. You can increase the number of opened files by configuring/usr/lib/systemd/system/mariadb. service.
Configure/usr/lib/systemd/system/mariadb. service
[Service] Add the following parameters:
Maid = 10000
LimitNPROC = 10000
Reload the system service and restart the mariadb service.
Systemctl -- system daemon-reload
Systemctl restart mariadb. service
Check the maximum number of connections of the mariadb database again. The maximum number of connections is already 1000.
MariaDB [(none)]> show variables like 'max _ connections ';
+ ----------------- + ------- +
| Variable_name | Value |
+ ----------------- + ------- +
| Max_connections | 1000 |
+ ----------------- + ------- +
The above operation method for setting the number of mysql connections (Too connections) is all the content that I have shared with you. I hope to give you a reference and support for the customer's house.