#show variables like 'have_query_cache';是否开启了缓存
#select @@global.query_cache_size; 缓存空间大小,如是0则缓存不可用
#select @@global.query_cache_type; on是sql语句都缓存;demand是仅仅缓存select sql_cache ...的查询
#set @@global.query_cache_size = 1000000; 设置缓存 1M
#set @@global.query_cache_type=demand; 设置缓存类型demand sql语句设置sql_cache才缓存
#reset query_cache;整理碎片
#flush tables; 清空缓存
#show status like 'qcache%' 查询缓存情况
#show status like 'qcache_q%'查询缓存结果集
#select sql_cache *from ky_users;
#show status like 'qcache_q%'
#show status like 'qcache_h%'
#select sql_cache *from ky_users;
#show status like 'qcache_h%'
#select @@global.query_cache_size; 缓存空间大小,如是0则缓存不可用
#select @@global.query_cache_type; on是sql语句都缓存;demand是仅仅缓存select sql_cache ...的查询
#set @@global.query_cache_size = 1000000; 设置缓存 1M
#set @@global.query_cache_type=demand; 设置缓存类型demand sql语句设置sql_cache才缓存
#reset query_cache;整理碎片
#flush tables; 清空缓存
#show status like 'qcache%' 查询缓存情况
#show status like 'qcache_q%'查询缓存结果集
#select sql_cache *from ky_users;
#show status like 'qcache_q%'
#show status like 'qcache_h%'
#select sql_cache *from ky_users;
#show status like 'qcache_h%'
show status like '%Com_select%';
可在my.ini中[mysqld]后添加
query_cache_size=128M
query_cache_type=1 //1代表on;2代表demand
query_cache_type=1 //1代表on;2代表demand