Thanks to @cwhisperer.
I had the same issue with Doctrine in a Symfony app. I just added the option to my config.yml:
doctrine:
dbal:
driver: pdo_mysql
options:
# PDO::MYSQL_ATTR_INIT_COMMAND
1002: "SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))"
This worked fine for me.