Sometimes we use the SET command to set the value of a variable, but we encounter some error message, that is: You cannot set this variable to "value".
Example:
Set global sql_log_bin=0;
The following error message is reported:
mysql> set global sql_log_bin=0;
ERROR 1231 (42000): Variable ' sql_log_bin ' can ' t is set to the value of ' 0 '
Official explanation: 5.5, 5.6, 5.7 does not support this variable global setting, will give the warning message, that is, the above information, after 5.7, will cancel the warning message
Here we are going to consider whether this is a global variable or a local variable.
But global variables and local variables are all Sql_log_bin
So I do the following:
Mysql> set session sql_log_bin=0;
Query OK, 0 rows Affected (0.00 sec)
Extended:
13.5.4.21. SHOW variables Syntax
SHOW [GLOBAL | SESSION] VARIABLES [like ' pattern ']
Show variables shows the value of the department MySQL system variable. This information can also be obtained using the mysqladmin variables command.
With the global option, you can get the values that are used for new MySQL connections. Using the session, you can get the values that are valid for the current connection. If none of your two options are used, the default value is session.
Local is synonymous with the session.
This article is from the "Phenex" blog, make sure to keep this source http://phenex.blog.51cto.com/10579566/1680785
MySQL global variables and local variables