本文介绍了MySQL 5.7中的max_connections的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,在通过编辑my.cnf将它设置为1000后,MySQL中的max_connction值为214,如下所示:

I met a problem, the value of max_connction in MySQL is 214 after I set it 1000 via edit the my.cnf, just like below:

hadoop@node1:~$ mysql -V
mysql  Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using  EditLine wrapper

MySQL版本:5.7

MySQL version: 5.7

操作系统版本:ubuntu 16.04LTS

OS version : ubuntu 16.04LTS

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.00 sec)

我们可以看到,max_connections的变量值为151.然后,我编辑MySQL的配置文件.

As we can see, the variable value of max_connections is 151. Then , I edit the configuration file of MySQL.

yang2@node1:~$ sudo vi /etc/mysql/my.cnf
[mysqld]

character-set-server=utf8
collation-server=utf8_general_ci
max_connections=1000

保存配置后重新启动MySQL服务.

Restart MySQL service after save the configraion.

yang2@node1:~$ service mysql restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'mysql.service'.
Multiple identities can be used for authentication:
 1.  yangqiang,,, (yang2)
 2.  ,,, (hadoop)
Choose identity to authenticate as (1-2): 1
Password:
==== AUTHENTICATION COMPLETE ===
yang2@node1:~$

现在,我们估计max_connection是1000,真的吗?

Now, we guess the max_connection is 1000, really?

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 214   |
+-----------------+-------+
1 row in set (0.00 sec)

现在是214.我不太了解这个结果,谁能帮助我?谢谢!

It is 214. I do not really understand this result, who can help me? thx!

推荐答案

作为 max_connections 设置为:

这意味着您的MySQL服务器可能没有足够的资源来维护所需数量的描述符.

This means that probably your MySQL server does not have enough resources to maintain the required number of descriptors.

MySQL如何打开和关闭表的MySQL文档明确指出:

这篇关于MySQL 5.7中的max_connections的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 08:40
查看更多