viewing and setting of [MySQL] variables (parameters)

Source: Internet
Author: User

Similar to Oracle's parameter files, MySQL's options files (such as MY.CNF) are used to configure the MySQL server, but unlike Oracle, in MySQL, the official called variable (varialbes), but actually called the parameter is also possible, Just understand that these two are the same thing. MySQL variables are divided into the following two types: 1) System variables: Configure the MySQL server's operating environment, you can use show variables to view 2) status variables: monitor the running status of the MySQL server, can be viewed with show status   System variable system variable according to its scope can be divided into the following two kinds: 1) into the global level: valid for the entire MySQL server 2) session (sessions or local) level: only affect the current session some variables have more than two levels at the same time, MySQL initializes session-level variables with global-level variables when the connection is established, but once the connection is established, changes to the global-level variables do not affect the conversation-level variables. Viewing the value of a system variable can see the value of the system variable through the show Vairables statement:[sql] mysql> show variables like ' log% ';  mysql> Show variables where variable_name like ' log% ' and value= ' on ';   NOTE: Show variables takes precedence over the value of the session-level variable, and if this value does not exist, the value of the global-level variable is displayed, and you can, of course, add the Global or Session keyword difference: [sql] show Global Variables  show session/local variables;   When writing some stored procedures, you may need to refer to the values of system variables, using the following methods: [sql] @ @GLOBAL. Var_name  @ @SESSION. Var_name or  @ @LOCAL. Var_ Name   If there is no level qualifier in front of the variable name, the session-level value is displayed first. The last way to view variable values is from the Global_variables and Session_variables tables in the INFORMATION_SCHEMA database.    setting and modifying the values of system variables when the MySQL server starts, there are two ways to set the values of the system variables: 1) command-line arguments, such as: Mysqld--max_connections=2002) option file (MY.CNF) after the MySQL server starts, if you need to modify the values of the system variables, you can pass the SET statement: [plain] set GLOBAL var_name = value;  set @ @GLOBAL. var_name = value;  set SESSION var_name = value;  set @ @SESSION. var_name = value;   If there is no level qualifier in front of the variable name, it means modifying the session-level variable. Note: Unlike startup, variables set at run time do not allow the suffix ' K ', ' M ', and so on, but can use expressions to achieve the same effect, such as: [Sql] set GLOBAL read_buffer_size = 2*1024*1024    Here's an easy place to put people in. If you are using show variables in your query, you will find that the settings do not appear to be in effect, because simply using show variables is equivalent to using the show session variables, the query is a session variable, only use show global variables, the query is the global variable.

Many people on the web complain that they have not found a change after set global using Show variables query, because they confuse session variables and global variables, and if you just want to modify session variables, you can use a set wait_timeout=10 or set session wait_timeout=10; Such a grammar. State variable state variables allow us to keep abreast of the health of the MySQL server and can be viewed using the show status statement. State variables are similar to the same variables, as well as global and session-level, and show status supports like matching queries, and the larger difference is that state variables can only be set and modified by the MySQL server itself, which is read-only for the user and cannot be set and modified by the SET statement.

viewing and setting of [MySQL] variables (parameters)

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.