Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql: modification in my.cnf doesn't take effect

Tags:

mysql

my.cnf

I've updated the my.cnf file of my database with the following line: max_connections=200. I stopped and started the mysql service after that so that the changes would take effect.

But for some reason this change doesn't affect the database because if I run:

mysql> select @@max_connections

it shows that the max number of connections is 100.

Obviously there is some place else that manages this value. Where can I find it or what did I do wrong?

Thank you for your reply.

like image 444
Ewoud Avatar asked Jan 25 '12 14:01

Ewoud


3 Answers

Make sure the max_connections in under the [mysqld] section:

Ex:

[mysqld]
socket=/path/to/mysql.sock
datadir=/var/lib/mysql
max_connections=200

[client]
#mysql-client settings here..
like image 117
Matt MacLean Avatar answered Sep 22 '22 18:09

Matt MacLean


Try running mysqld --verbose --help to see which configuration file is actually read by mysqld and which parameters and values are used. The output will look like this:

mysqld  Ver 5.0.51a-24-log for debian-linux-gnu on x86_64 ((Debian))
Copyright (C) 2000 MySQL AB, by Monty and others
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
The following groups are read: mysql_cluster mysqld server mysqld-5.0

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- -----------------------------
...

To see what values a running MySQL server is using, type
'mysqladmin variables' instead of 'mysqld --verbose --help'.

like image 39
Marki555 Avatar answered Sep 21 '22 18:09

Marki555


It may have to do with 'how' the mysql server is being shutdown and restarted. On my system if I use the mysqld daemon service to shutdown mysql (e.g. service mysqld stop), I get a shutdown notice, but a ps shows mysql is still running. Using a similar 'service mysqld restart', some of the changes to the my.cnf file get accepted, but many don't.

The other method of shutting down mysql is to use mysqladmin -u user -pPass shutdown. I noticed when I used this method, mysql was shutdown completely (no left overs in ps), and when I restarted the mysql server, all the changes to the my.cnf file were accepted.

like image 22
WxWizard Avatar answered Sep 22 '22 18:09

WxWizard