MYSQL sql_mode Keeps reseting


mysql Ver 14.14 Distrib 5.7.38, for Linux (x86_64) using EditLine wrapper

Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic

MYSQL Keeps reseting my sql_mode and so my website is not working well.

The MySQL message is the following

Expression #18 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'testdevnew.f.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

What I do till now is from terminal to connect inside mysql with the command

mysql -u root -p

and run the following commands



And the error is gone, but for a couple of days… lets say that we restart mysql server and the above settings are gone.

Also tried to change the following files with the sql_mode that i would like to load after mysql restart.

File list





(I’ve also tried with value in quotes)

Then restart mysql

sudo service mysql restart

But the setting is not affecting mysql restart and I keep getting the error mentioned above.

mysqld --verbose --help

prints the following


Any ideas of what am I doing wrong?

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 11, 2022

Hi there,

I’ve just tested this and it seems to be working well when the change is added to the /etc/mysql/mysql.conf.d/mysqld.cnf file under the [mysqld] section.

Do you see any errors in your MySQL error log that could indicate on what the issue might be?

  1. tail -100 /var/log/mysql/error.log

Also check for any other references of sql_mode:

grep -r sql_mode /etc/mysql/*

You might have to remove the duplicate ones.