SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern
']
SHOW VARIABLES
shows the values
of MySQL system variables. This information also can be obtained
using the mysqladmin variables command. This
statement does not require any privilege. It requires only the
ability to connect to the server.
The GLOBAL
and SESSION
modifiers are new in MySQL 4.0.3. With the
GLOBAL
modifier, SHOW
VARIABLES
displays the values that are used for new
connections to MySQL. With SESSION
, it
displays the values that are in effect for the current
connection. If no modifier is present, the default is
SESSION
. LOCAL
is a
synonym for SESSION
.
If the default system variable values are unsuitable, you can
set them using command options when mysqld
starts, and most can be changed at runtime with the
SET
statement. See Section 5.1.5, “Using System Variables”, and
Section 12.4.4, “SET
Syntax”.
Partial output is shown here. The list of names and values may be different for your server. Section 5.1.3, “Server System Variables”, describes the meaning of each variable, and Section 7.5.3, “Tuning Server Parameters”, provides information about tuning them.
mysql> SHOW VARIABLES;
+---------------------------------+------------------------------+
| Variable_name | Value |
+---------------------------------+------------------------------|
| back_log | 50 |
| basedir | /usr/local/mysql |
| bdb_cache_size | 8388572 |
| bdb_log_buffer_size | 32768 |
| bdb_home | /usr/local/mysql |
...
| max_connections | 100 |
| max_connect_errors | 10 |
| max_delayed_threads | 20 |
| max_error_count | 64 |
| max_heap_table_size | 16777216 |
| max_join_size | 4294967295 |
| max_relay_log_size | 0 |
| max_sort_length | 1024 |
...
| timezone | EEST |
| tmp_table_size | 33554432 |
| tmpdir | /tmp/:/mnt/hd2/tmp/ |
| version | 4.1.18 |
| wait_timeout | 28800 |
+---------------------------------+------------------------------+
With a LIKE
clause, the statement
displays only rows for those variables with names that match the
pattern. To obtain the row for a specific variable, use a
LIKE
clause as shown:
SHOW VARIABLES LIKE 'max_join_size'; SHOW SESSION VARIABLES LIKE 'max_join_size';
To get a list of variables whose name match a pattern, use the
“%
” wildcard character in a
LIKE
clause:
SHOW VARIABLES LIKE '%size%'; SHOW GLOBAL VARIABLES LIKE '%size%';
Wildcard characters can be used in any position within the
pattern to be matched. Strictly speaking, because
“_
” is a wildcard that matches
any single character, you should escape it as
“\_
” to match it literally. In
practice, this is rarely necessary.
User Comments
This SHOW command can also be used in conjunction with WHERE. For example, to show all variables that have a numeric setting higher then zero, you can use:
SHOW VARIABLES WHERE VALUE > 0;
Or, if you would like to see all variables, except the storage engine specific ones, you can use the following expression:
SHOW VARIABLES WHERE Variable_Name NOT LIKE '%myisam%' AND Variable_Name NOT LIKE '%innodb%';
Add your own comment.