Types Of System Variables
-
mysqld maintains two kinds of system variables.
- Global variables, that affect the overall operation of the server.
- Session variables, that affect its operation for individual client connections.
- System variable values can be set globally at server startup by using options on the command line or in an option file.
- A system variable can have both a global value and a session value.
- Global and session system variables are related as follows:
- When the server starts, it initializes all global variables to their default values.
- These defaults can be changed by options specified on the command line or in an option file.
- The server also maintains a set of session variables for each client that connects.
- The client's session variables are initialized at connect time using the current values of the corresponding global variables.
- The
SUPER privilege is required to set global variables.
- To indicate explicitly that a variable is a global variable, precede its name by
GLOBAL or @@global.
SET GLOBAL variable=value
- Setting a session variable requires no special privilege.
- A client can change only its own session variables.
- It not change those of any other client.
- To indicate explicitly that a variable is a global variable, precede its name by
SESSION or @@session.
SET SESSION variable=value
LOCAL and @@local. are synonyms for SESSION and @@session.
How do I set variables?
© 2007 John Michael Pierobon
Notes