2020-08-14 MySQL查看数据库性能常用命令

MySQL查看数据库性能常用命令
mysql> show global status; 列出MySQL服务器运行各种状态值
mysql> show variables; 查询MySQL服务器配置信息语句

一、慢查询   
  mysql> show variables like '%slow%';
  mysql> show global status like '%slow%';

二、连接数
  mysql> show variables like 'max_connections'; max_connections值过小:
  mysql> show global status like ‘Max_used_connections’;

三、Key_buffer_size   
  mysql> show variables like ‘key_buffer_size’; 以MyISAM为主要存储引擎服务器的配置
  mysql> show global status like 'key_read%'; key_buffer_size的使用情况
  mysql> show global status like 'key_blocks_u%'; key_blocks_*参数

四、临时表
  mysql> show global status like 'created_tmp%';
  mysql> show variables where Variable_name in ('tmp_table_size', 'max_heap_table_size'); MySQL服务器对临时表的配置

五、Open Table情况
  mysql> show global status like 'open%tables%'; Open_tables表示打开表的数量,Opened_tables表示打开过的表数量
  mysql> show variables like 'table_cache'; 服务器table_cache值

六、进程使用情况
  mysql> show global status like ‘Thread%’; Threads_created表示创建过的线程数
  mysql> show variables like 'thread_cache_size'; 查询服务器thread_cache_size配置

七、查询缓存(query cache)
  mysql> show global status like 'qcache%';
  mysql> show variables like 'query_cache%'; 服务器关于query_cache的配置

八、排序使用情况
  mysql> show global status like 'sort%';

九、文件打开数(open_files)
  mysql> show global status like 'open_files';

十、表锁情况
  mysql> show global status like 'table_locks%';

十一、表扫描情况
  mysql> show global status like 'handler_read%';
  mysql> show global status like 'com_select'; 调出服务器完成的查询请求次数

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。