One, MySQL variable type:
MySQL uses variables to define the current server's characteristics, save state information, and so on. We can configure MySQL by manually changing the value of the variable, or we can get the current state information of MySQL through a variable. The variable type of MySQL can be divided from the way variables are modified and the scope of the variables to be effective.
1. Depending on how the variable is modified:
Dynamic variables: You can adjust the meaning of the MySQL runtime and take effect immediately;
Static variables: Need to be modified in the configuration file, restart the service after the effective;
2. Depending on the scope of the variable to take effect:
Global variables: Service level settings, for the entire service to take effect;
Session variables: Only valid for the current session, other sessions and new session are not affected, session end value is destroyed;
Second, see the variables for MySQL: 1. View the variables that can be defined in the configuration file:
shell> mysqld--help--verbose
2. Check the current runtime variables of the MySQL service:
"' ];mysql> SELECT @@{global| SESSION}. Variable_name;mysql> SELECT * from INFORMATION_SCHEMA. Global_variables WHERE variable_name='variable_name'; MySQL> SELECT * FROM Information_schema. Session_variables WHERE variable_name='variable_name';
Third, modify the MySQL variable: 1. Modify the configuration file:
With configuration file modification, you only need to specify the variable and value in the configuration file, restart the service, for example:
Shell> vim/etc/my.cnf
1
Shell> Service mysqld Restart
Variables modified through the configuration file are permanently active.
2. Direct modification at runtime:
The run-time modification uses the SET command and specifies the variable type (global or session) to assign a value to, for example:
11
It is important to note that the values that are modified at run time in the global variable are not permanently valid, are invalidated after a reboot, and are invalidated if the session variable is the.
MySQL service-MySQL variable type and variable settings