Command-Line Format | --sort_buffer_size=# |
||
System Variable | Name | sort_buffer_size |
|
Variable Scope | Global, Session | ||
Dynamic Variable | Yes |
Command-Line Format | --query_cache_size=# |
||
System Variable | Name | query_cache_size |
|
Variable Scope | Global | ||
Dynamic Variable | Yes |
mysql> use information_schema Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables like '%VARIABLE%'; +-------------------------------------------+ | Tables_in_information_schema (%VARIABLE%) | +-------------------------------------------+ | GLOBAL_VARIABLES | | SESSION_VARIABLES | +-------------------------------------------+ 2 rows in set (0.00 sec) mysql> desc GLOBAL_VARIABLES; +----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------+------+-----+---------+-------+ | VARIABLE_NAME | varchar(64) | NO | | | | | VARIABLE_VALUE | varchar(1024) | YES | | NULL | | +----------------+---------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> show variables like '%innodb_buffer_pool_size%'; +-------------------------+-----------+ | Variable_name | Value | +-------------------------+-----------+ | innodb_buffer_pool_size | 134217728 | +-------------------------+-----------+ 1 row in set (0.00 sec) mysql> set global innodb_buffer_pool_size=104857600; ERROR 1238 (HY000): Variable 'innodb_buffer_pool_size' is a <span style="background-color: rgb(255, 0, 0);">read only variable</span>
mysql> show variables like '%sort_buffer%'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | innodb_sort_buffer_size | 1048576 | | myisam_sort_buffer_size | 8388608 | | sort_buffer_size | 262144 | +-------------------------+---------+ 3 rows in set (0.00 sec) mysql> set global sort_buffer_size=1048576; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%sort_buffer%'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | innodb_sort_buffer_size | 1048576 | | myisam_sort_buffer_size | 8388608 | | sort_buffer_size | 262144 | +-------------------------+---------+ 3 rows in set (0.00 sec) mysql> exit Bye [root@mysqlrep2 ~]# /usr/local/mysql/bin/mysql -uroot -p -S /dbdata/data/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.27 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%sort_buffer%'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | innodb_sort_buffer_size | 1048576 | | myisam_sort_buffer_size | 8388608 | | sort_buffer_size | 1048576 | +-------------------------+---------+ 3 rows in set (0.00 sec)
mysql> set sort_buffer_size=1000000; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%sort_buffer%'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | innodb_sort_buffer_size | 1048576 | | myisam_sort_buffer_size | 8388608 | | sort_buffer_size | 1000000 | +-------------------------+---------+ 3 rows in set (0.00 sec) mysql> mysql> mysql> exit Bye [root@mysqlrep2 ~]# /usr/local/mysql/bin/mysql -uroot -p -S /dbdata/data/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.27 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%sort_buffer%'; +-------------------------+---------+ | Variable_name | Value | +-------------------------+---------+ | innodb_sort_buffer_size | 1048576 | | myisam_sort_buffer_size | 8388608 | | sort_buffer_size | 1048576 | +-------------------------+---------+ 3 rows in set (0.00 sec) mysql> mysql>
mysql> mysql> show variables like '%query_cache_size%'; +------------------+---------+ | Variable_name | Value | +------------------+---------+ | query_cache_size | 1048576 | +------------------+---------+ 1 row in set (0.00 sec) mysql> set query_cache_size=1000000; ERROR 1229 (HY000): Variable 'query_cache_size' is a <span style="background-color: rgb(255, 0, 0);">GLOBAL variable</span> and should be set with SET GLOBAL
mysql> set global query_cache_size=10485760; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%query_cache_size%'; +------------------+----------+ | Variable_name | Value | +------------------+----------+ | query_cache_size | 10485760 | +------------------+----------+ 1 row in set (0.00 sec) mysql> exit Bye [root@mysqlrep2 ~]# /usr/local/mysql/bin/mysql -uroot -p -S /dbdata/data/mysql.sock Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.27 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%query_cache_size%'; +------------------+----------+ | Variable_name | Value | +------------------+----------+ | query_cache_size | 10485760 | +------------------+----------+ 1 row in set (0.00 sec)
status是数据库运行状态的记录或统计
如Bytes_received,Bytes_sent。
com_xxx 记录的是数据库运行的命令的统计,比如Com_delete是运行的delete命令的次数统计,类似的还有Com_drop_index等。
FLUSH STATUS
statement.
以Com_show_status
Com_show_status |
integer | GLOBAL | SESSION |
当前系统总的统计是10次
mysql> show global status; +-----------------------------------------------+-------------+ | Variable_name | Value | +-----------------------------------------------+-------------+ ............ | Com_show_slave_status | 0 | | Com_show_status | 10 | | Com_show_storage_engines | 0 | ............ +-----------------------------------------------+-------------+ 341 rows in set (0.00 sec) mysql>
当前session运行了3次
mysql> show status; +-----------------------------------------------+-------------+ | Variable_name | Value | +-----------------------------------------------+-------------+ ............ | Com_show_slave_status | 0 | | Com_show_status | 3 | | Com_show_storage_engines | 0 | ............ +-----------------------------------------------+-------------+ 341 rows in set (0.00 sec)
把当前session的统计清0
系统统计的总的次数不受影响
mysql> flush status; Query OK, 0 rows affected (0.00 sec) mysql> show global status; +-----------------------------------------------+-------------+ | Variable_name | Value | +-----------------------------------------------+-------------+ ............ | | Com_show_slave_status | 0 | | Com_show_status | 12 | | Com_show_storage_engines | 0 | ............ +-----------------------------------------------+-------------+ 341 rows in set (0.00 sec) mysql>
mysql> show status; +-----------------------------------------------+-------------+ | Variable_name | Value | +-----------------------------------------------+-------------+ ............ | Com_show_slave_status | 0 | | Com_show_status | 2 | | Com_show_storage_engines | 0 | ............ +-----------------------------------------------+-------------+ 341 rows in set (0.00 sec) mysql>