MySQL error : sql_mode=only_full_group_by

Discussions related with hosting control panels used, which include cPanel, Plesk, Directadmin etc..

Moderator: Staff

Post Reply
John Stanley
Posts: 0
Joined: Wed Sep 28, 2016 10:50 am

MySQL error : sql_mode=only_full_group_by

Post by John Stanley »

Hello,

I have this script where I'm used to doing a simple projection for a dynamic result but something goes wrong ; as i have this error :

1055 - Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mutuelle_bi.M.etat_bs' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

How may i modify my script, by the way, to solve this problem , given that I shouldn't modify any config file of my sql server . and i should only write scripts

Any Suggestions to fix this issue asap??


Aaron
Posts: 17
Joined: Mon Apr 11, 2016 8:59 am

Re: MySQL error : sql_mode=only_full_group_by

Post by Aaron »

Hello,

You can try to disable the only_full_group_by setting in the MySQL configuration

Go to MySQL prompt and use the command listed below.

Code: Select all

set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
If you want to set these modes permanently then you need to edit your MySQL conf like below.

Code: Select all

sudo vi /etc/mysql/my.cnf
Scroll to the bottom of file and press 'i' to enter insert mode
Copy and paste

Code: Select all

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION to the bottom of the file
esc to exit input mode
:wq to save and close vi editor.
sudo service mysql restart to restart MySQL.
Done!


Aaron N
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php

Follow us on : https://twitter.com/nixtree
If you are looking for assistance in server management, please get in touch with our support.
Post Reply