jimmy_code
jimmy_code

Reputation: 91

why mysql @@variables do not match the content of my.cnf file?

I can see that variables inside /etc/mycnf file are different from the variables that i see through 'show variables' command, how is this possible? how can i fix this?

For example the output given by the following command: show variables like '%data%'; gives different variables output with respect to the ndf file.

Upvotes: 1

Views: 1308

Answers (1)

FantomX1
FantomX1

Reputation: 1711

Be sure to have it in the correct, corresponding section of the my.cnf configuration file once you are convinced you have it inside the correct my.cnf file, or the one with the highest priority.

My example case was I had it previously under various sections [mariadb], [mysqld], [mysql], [client-server] , whereas my setting log_slow_queries needed to be under the section name [server] which was not even there, I just figured it out by trial and error.

To be pretty sure the given file is the correct one to use, try to add a setting log_slow_queries under the [mysql] field and it will complain as it's the server setting and the [mysql] section is for the client configurations, but if it will complain with an error you know that .cnf file is used and when it's tested via a CLI client, the server error are usually suppressed and quite often not available even in the logs .

Or you can find out exactly which files are read by mysql/mariadb server by issuing this command

mysqladmin --help | grep -A1 'Default options' or

strace mysql ";" 2>&1 | grep cnf or

mysqld --help --verbose | grep my.cnf

command journalctl -xe for investigating a few recent related errors with mysql service

Upvotes: 1

Related Questions