gpt4 book ai didi

mysql - MySQL 5.7 中的 max_connections

转载 作者:IT老高 更新时间:2023-10-29 00:10:53 25 4
gpt4 key购买 nike

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

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

MySQL 版本:5.7

操作系统版本: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的配置文件。

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

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

保存配置后重启MySQL服务。

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,真的吗?

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

是214,这个结果我不太明白,谁能帮帮我?谢谢!

最佳答案

您可以手动设置该值,例如

set global max_connections=500;

但是,在 MySQL 重新启动后,该值会重置为 214。

解决方案取决于操作系统(版本)和 MySQL 版本。在 Ubuntu 16.04 和 MySQL >= 5.7.7 下可以使用:

systemctl 编辑 mysql

输入

[Service]
LimitNOFILE=8000

保存,这将创建一个新文件

/etc/systemd/system/mysql.service.d/override.conf

然后重启服务器:

systemctl daemon-reload
systemctl restart mysql

对于其他环境:Can not increase max_open_files for Mysql max-connections in Ubuntu 15

关于mysql - MySQL 5.7 中的 max_connections,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39976756/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com