Disabling sql_mode=only_full_group_by in mysql 5.7 ubuntu 18.04

Sometimes it happens that you need to start an old site on new software. In my case, a site running on mysql 5.5 needed to be debugged on mysql 5.7. There was also an error "42000":

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'db.books' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

This is all due to the fact that mysql 5.7 introduced rules that, in order to speed up work with the database, prevent some queries from working (if I understood correctly). In production, this request should be rewritten. Because performance will be lost. But on a locale, you can perform the actions described below.

Tried for Ubuntu 18.04, mysql 5.7 (as I wrote above).

Add the following lines to the end of the /etc/mysql/my.cnf file:

sudo nano /etc/mysql/my.cnf

Enter at the end :

[mysqld]
sql_mode="NO_ENGINE_SUBSTITUTION"

restart mysql

sudo service mysql stop

sudo service mysql start

A warning

Initially, in 5.7 sql_mode, the following keys work:

STRICT_TRANS_TABLES, ONLY_FULL_GROUP_BY, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION

With our action, we disable all keys, driving mysql 5.7 into a non-standard mode of operation, similar to mysql 5.6 version.

Don't use this in production.

4460 0

Comments

Be the first to review this item. Share your rating and review so that other customers can decide if this is the right item for them.
You have to log in to leave a comment. Sign in

Similar articles

Mysql database of tires and disks

Base of automobile tires and disks. The database contains: manufacturer, model, year, modification, PCD, diameter, nut, tire and wheel factory sizes, possible replacement options, tire and wheel tuning. There are no trucks in the database.