MySQL global variables and local variables

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.