MySQL MariaDB - 无法通过 my.cnf 设置 max_connections
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37021326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MariaDB - cannot set max_connections through my.cnf
提问by Iokanaan Iokan
I am struggling to set max_connections parameter in /etc/my.cnf but MariaDB does not seem to read the parameter from the file.
我正在努力在 /etc/my.cnf 中设置 max_connections 参数,但 MariaDB 似乎没有从文件中读取参数。
My /etc/my.cnf file:
我的 /etc/my.cnf 文件:
[mysqld]
#skip-grant-tables
datadir=/data/mysql
socket=/data/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# network
connect_timeout = 60
wait_timeout = 28800
max_connections = 100000
max_allowed_packet = 64M
max_connect_errors = 1000
# limits
tmp_table_size = 512M
max_heap_table_size = 256M
table_cache = 512
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
[client]
port = 3306
socket= /data/mysql/mysql.sock
But when I check the variable in MariaDB, it shows the default value:
但是当我检查 MariaDB 中的变量时,它显示了默认值:
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set (0.00 sec)
However, other parameters in my.cnf are correct:
但是,my.cnf 中的其他参数是正确的:
MariaDB [(none)]> show variables like 'wait_timeout';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout | 28800 |
+---------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| max_allowed_packet | 67108864 |
+--------------------+----------+
1 row in set (0.00 sec)
MariaDB [(none)]> show variables like 'max_connect_errors';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| max_connect_errors | 1000 |
+--------------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> show variables like 'connect_timeout';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| connect_timeout | 60 |
+-----------------+-------+
1 row in set (0.00 sec)
I can set this variable from mysql command line but it resets itself when I restart the service:
我可以从 mysql 命令行设置这个变量,但是当我重新启动服务时它会自行重置:
MariaDB [(none)]> set global max_connections := 10000;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 10000 |
+-----------------+-------+
1 row in set (0.00 sec)
OS: RHEL 7
操作系统:RHEL 7
MariaDB version: mariadb-server-5.5.47-1.el7_2.x86_64
MariaDB 版本:mariadb-server-5.5.47-1.el7_2.x86_64
请参阅此处:https: //dba.stackexchange.com/questions/137487/mariadb-cannot-set-max-connections-and-wait-timeout-through-my-cnf
回答by mootmoot
I think the solution is here. Increase your open files limit .
我认为解决方案就在这里。增加您的打开文件限制。
https://dba.stackexchange.com/questions/12061/mysql-auto-adjusting-max-connections-values
https://dba.stackexchange.com/questions/12061/mysql-auto-adjusting-max-connections-values
回答by Ket.
I have same issue on ubuntu server. nd i have change this file /etc/mysql/my.cnf
我在 ubuntu 服务器上有同样的问题。我改变了这个文件 /etc/mysql/my.cnf
max_connections = 1000
then execute the query . you are changing wrong file.
然后执行查询。您正在更改错误的文件。
回答by Strix
In Ubuntu server with Maria DB enter parameter max connectionsin /etc/mysql/mariadb.conf.d/50-server.cnf
在带有 Maria DB 的 Ubuntu 服务器中,在/etc/mysql/mariadb.conf.d/50-server.cnf 中输入参数max connections
Restart the service for changes to take effect.
重新启动服务以使更改生效。
systemctl restart mariadb