Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MariaDB - cannot set max_connections through my.cnf

Tags:

mysql

mariadb

I am struggling to set max_connections parameter in /etc/my.cnf but MariaDB does not seem to read the parameter from the file.

My /etc/my.cnf file:

[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 [(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:

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:

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

MariaDB version: mariadb-server-5.5.47-1.el7_2.x86_64

See here: https://dba.stackexchange.com/questions/137487/mariadb-cannot-set-max-connections-and-wait-timeout-through-my-cnf

like image 937
Iokanaan Iokan Avatar asked May 04 '16 07:05

Iokanaan Iokan


People also ask

How many concurrent connections can MariaDB handle?

By default, MariaDB is configured for 150 connections plus one for root access if not already used (so 151 connections). In most cases, 150 is really enough, but it might not be in your case if you've got a lot of connection errors on your application.

What is Max_connections?

max_connections is a global variable that can have a minimum value of 1 and a maximum value of 100000. However, It has always been commonly known that settings max_connections to an insanely high value is not too good for performance. Generations of system administrators have followed this rule.


2 Answers

I think the solution is here. Increase your open files limit .

https://dba.stackexchange.com/questions/12061/mysql-auto-adjusting-max-connections-values

like image 104
mootmoot Avatar answered Oct 25 '22 18:10

mootmoot


I have same issue on ubuntu server. nd i have change this file /etc/mysql/my.cnf

max_connections = 1000

then execute the query . you are changing wrong file.

like image 38
Ket. Avatar answered Oct 25 '22 16:10

Ket.