I wanted to disable the ONLY_FULL_GROUP_BY value of sql-mode permanently even restart the MySQL server. following things I have tried to do but which are not working. that set to the default value when restarting the MySQL.
Persisted settings are permanent. They apply across server restarts.
set PERSIST sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
have you tried this?
Using SET GLOBAL to change a variable only changes it for the current MySQL Server process. If the server restarts, changes are reverted. Global variable settings are read from the MySQL Server options file upon startup.
In MySQL 8.0, they added a SET PERSIST command so you can change a global variable and add the setting to the options file at once. Read https://dev.mysql.com/doc/refman/8.0/en/persisted-system-variables.html
If you use an older version of MySQL, you'll have to edit the options file. Editing the options file alone does not change the option in the running MySQL Server instance. You would need to restart the MySQL Server to get it to re-read the options file.
My usual habit is to do both — edit the options file and then also run SET GLOBAL to change it to the same value. That ensures it will be the same after a restart, but it allows me to make the change immediately without restarting.
That said, I recommend you should not disable ONLY_FULL_GROUP_BY. That mode protects you from writing invalid SQL queries.
You can use "SET PERSIST" since MySQL 8.0 to persist "sql_mode" global system variable without ONLY_FULL_GROUP_BY to "mysqld-auto.cnf" as shown below so that "sql_mode" global system variable is not reset after restarting MySQL:
SET PERSIST sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
In addition, with the command below, you can check all persisted system variables in "mysqld-auto.cnf":
mysql> SELECT * FROM performance_schema.persisted_variables;
+-----------------+----------------------------------------------------------------------------------------------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+-----------------+----------------------------------------------------------------------------------------------------+
| sql_mode | STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
| max_connections | 500 |
+-----------------+----------------------------------------------------------------------------------------------------+
And, with the command below, you can remove all persisted system variables from "mysqld-auto.cnf":
RESET PERSIST;
And, with the command below, you can remove only "sql_mode" persisted system variable from "mysqld-auto.cnf":
RESET PERSIST sql_mode;
And, with the command below, you can reset "sql_mode" global system variable:
SET ##GLOBAL.sql_mode = DEFAULT;
Now, "sql_mode" global system variable has the default values with ONLY_FULL_GROUP_BY as shown below:
mysql> SELECT ##GLOBAL.sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| ##GLOBAL.sql_mode |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
I am facing a problem while creating a function in MySql :
You do not have the SUPER privilege and
binary logging is enabled (you *might* want to use the less safe
log_bin_trust_function_creators variable)
While searching I found that below command will fix the issue
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Do I really need to shutdown MySql server to set Global variable log_bin_trust_function_creators ?
No, you do not have to restart mysql to change this setting. The mysql manual says it is a dynamic variable, so it can be changed via the set statement in your question.
I have removed ONLY_FULL_GROUP_BY from sql_mode. The following query returns no modes enabled.
SELECT ##GLOBAL.sql_mode;
But still when using group by, I am receiving non-aggregated columns
(this is incompatible with sql_mode=only_full_group_by) error.
Option 1: Remove Globally ONLY_FULL_GROUP_BY using query
mysql> SET GLOBAL sql_mode=(SELECT REPLACE(##sql_mode,'ONLY_FULL_GROUP_BY',''));
mysql>SET ##sql_mode=REPLACE(##sql_mode, 'ONLY_FULL_GROUP_BY', '');
Refer: http://johnemb.blogspot.com.ng/2014/09/adding-or-removing-individual-sql-modes.html
Option 2: Set sql_mode to nothing...
mysql> SET GLOBAL sql_mode = '';
Option 3: Remove Globally ONLY_FULL_GROUP_BY from phpmyadmin
Open phpmyadmin & select localhost
Click on menu Variables & scroll down for sql mode
Click on edit button to change the values & remove ONLY_FULL_GROUP_BY & click on save.
According to the mysql documentation this flag is possible to change dynamically.
Property Value
Command-Line Format --general-log
System Variable general_log
Scope Global
Dynamic Yes
SET_VAR Hint Applies No
Type Boolean
Default Value OFF
But by default this option is disabled. But I need to enable this flag in order to see the logs without restarting the server. What is the way to enable this without restarting the server.
MySQL provides a System variable general_log, which specifies whether the general query log is enabled or not. You will just need to execute the following queries to enable GLOBAL logging (for all the other client sessions as well):
SET GLOBAL general_log = 'ON';
You can also specify the log file path:
SET GLOBAL general_log_file = '/var/log/mysql/all.log';
Remember that when you restart the server, these settings will be lost. To make the changes persistent, you will have to make changes in the configuration file.
If you want to disable the general query logging, you can do the following:
SET GLOBAL general_log = 'OFF'
I absolutely need to unset ONLY_FULL_GROUP_BY on my VPS server hosted by OVH
So I use the command
mysql > SET GLOBAL sql_mode=(SELECT REPLACE(##sql_mode,'ONLY_FULL_GROUP_BY',''));
found here
But I don't why or who automatically reset this flag the day after.
Could you give me some ideas to find what happens??
Can phpMyAdmin set this mode ??
I had the same issue and solved by using the following tutorial
https://www.sitepoint.com/quick-tip-how-to-permanently-change-sql-mode-in-mysql/