mysql优化笔记

 query_cache_size

查询缓存

query_cache_type
缓存是否打开 OFF/ON

read_buffer_size
读缓存
SET GLOBAL query_cache_size=1024*1024*100;

查看查询缓存
show global variables like 'max_heap_table_size';

--动态启用查询缓存
show variables like 'query_cache%';
SET GLOBAL query_cache_type=1;
SET GLOBAL query_cache_size=1024*1024*100;
--系统变量
show global variables like 'slow_query_log';
show global variables like 'slow_query_log_file';
show global variables like 'long_query_time';
show global variables like 'max_allowed_packet';
show global variables like 'wait_timeout';
show global variables like 'interactive_timeout';

set global long_query_time=1;
set global slow_query_log_file='/usr/local/mysql/data/itcast_log_2013-9-15.log';
set global slow_query_log_file ='d:/mysql_logs/mysql_logs.log'

--设置mysql参数
set max_heap_table_size=32777216

--设置数据库连接数
set global max_connections=150

1 连接数
SHOW VARIABLES LIKE 'max_connections';

2 缓存设置
show variables like 'key_buffer_size';
key_buffer_size是对myisam表性能影响最大

3 进程使用情况
show global status like 'thread%';

4.表锁情况
show global status like 'table_locks%';

5.清理碎片
flush query cache;

原文地址:https://www.cnblogs.com/kedoudejingshen/p/6238874.html