[MySQL] Disable the ONLY_FULL_GROUP_BY restriction
Customize MySQL configuration
Example of disable the ONLY_FULL_GROUP_BY restriction:
- Check the current sql_mode setting in
mysql:SELECT @@GLOBAL.sql_modeand copy the result. - Stop mysql service:
$ sudo /etc/init.d/mysql stopor$ sudo systemctl stop mysql List the configuration files:
$ mysql --help | grep 'my.cnf'To disable ONLY FULL GROUP BY in MySQL 5.7
Added this line in the bottom of
/etc/mysql/mysql.conf.d/mysqld.cnfsql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
For MySQL 8.0
Create custom
*.cnffile under/etc/mysql/conf.d/directory:$ sudo vim /etc/mysql/conf.d/disable_full_group_by.cnfContent of
disable_full_group_by.cnf[mysqld] # Note: Origin sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
Reboot mysql service to see if the modification works
- Reboot mysql service:
$ sudo /etc/init.d/mysql startor$ sudo systemctl start mysql - Login
mysqland check the result:SELECT @@GLOBAL.sql_mode
⤧ Previous post [Obsidian] Change Monospace Font In The Markdown Editor ⤧ Next post [PHP] Setup Xdebug with VS Code for macOS