This content is reproduced on-line collection
Variables are divided into user variables and system variables
User variables are related to database connections, and variables declared in this connection disappear when the connection is broken.
A variable declared in this connection cannot be used in another connection.
The variable name of the user variable is in the form of @varname.
The name must begin with @.
When declaring a variable, you need to use a SET statement, such as the following statement that declares a variable named @a.
System variables:
The system variables are divided into global variables and session variables.
Global variables are automatically initialized by the server to default values when MySQL is started, and these defaults can be changed by changing the My.ini file.
Session variables are initialized by MySQL each time a new connection is established. MySQL copies the values of all the current global variables in one copy. To be a session variable.
(That is, if you do not manually change the value of the session variable and the global variable after the session has been established, the values of all these variables are the same.) )
The difference between a global variable and a session variable is that the modification of the global variable affects the entire server, but changes to the conversation variable affect only the current session
(that is, the current database connection).
We can use
Show session variables;
Statement to output all session variables:
(Can be abbreviated as show variables, without specifying whether to output global variables or session variables, the default is to output session variables.) )
If you want to output all global variables:
Show global variables;
The MySQL variable