Report this

What is the reason for this report?

sql_mode=only_full_group_by

Posted on September 16, 2019

I have an ubuntu 18.04 connected with a shared mysql, both fresh installations. Yesterday I transfered the website and everything looked fine so far. This morning I realised that the search function is not working at all on wp-admin. Check the errors and I got this

WordPress database error Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'dbname.lt.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by for query 

Any ideas as the mysql server is shared and I can’t change that.

Thanks G.



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!

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.

Hello,

What is the WordPress version that you are using?

As far as I can see with the latest WordPress version there is a set_sql_mode method that auto checks the sql_mode and ensures that the correct one is set for the current session:

https://github.com/WordPress/WordPress/blob/master/wp-includes/wp-db.php

If you are already using the latest one and it still does not work, I think that you might have to contact your SQL provider and ask them if they could adjust this for you.

Regards, Bobby

Hi,

Sure!

Although is the latest wp version I managed to solve this problem by using the following function on functions.php

add_action( 'init', 'mysqlfix',-1 );

function mysqlfix() {
	global $wpdb;
	# Removed ONLY_FULL_GROUP_BY
	$wpdb->set_sql_mode("SET SESSION sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'");
}

Technicians from DO said they will let me know when is fixed on their side so I won’t need this piece of code anymore. Still haven’t heard form them.

Thanks, Giorgos

Hi all,

now we dont need any custom code on function or wherever else. You can easily control these options from database dashboard on DO admin panel.

Here you got all information. https://www.digitalocean.com/docs/databases/mysql/how-to/set-sql-mode/

Thanks, Giorgos

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.