加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

如何查看MySQL功能

发布时间:2022-01-12 04:51:09 所属栏目:MySql教程 来源:互联网
导读:这篇文章给大家分享的是有关如何查看MySQL性能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。 如何查看MySQL性能? 现在大家对MySQL的监控通常有两种做法,一是连接到mysql数据库内部,使用show status,show variables,flu
        这篇文章给大家分享的是有关如何查看MySQL性能的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
 
如何查看MySQL性能?
 
      现在大家对MySQL的监控通常有两种做法,一是连接到mysql数据库内部,使用show status,show variables,flush status 来查看mysql的各种性能指标;二是直接使用mysqladmin查看其性能指标。
 
方法一的使用:
 
查看MySQL服务器配置信息 :mysql> show variables;
查看MySQL服务器运行的各种状态值 :mysql> show global status;
慢查询:mysql> show variables like '%s%';
mysql> show global status like '%slow%';
连接数:mysql> show variables like 'max_connections';
key_buffer_size 是对MyISAM表性能影响最大的一个参数mysql> show variables like 'key_buffer_size';
临时表:mysql> show global status like 'created_tmp%';
查看open table :mysql> show global status like 'open%tables%';
进程使用情况:mysql> show global status like 'Thread%';
查询缓存(query cache) :mysql> show global status like 'qcache%';
文件打开数(open_files) :mysql> show global status like 'open_files';
表锁情况 :mysql> show global status like 'table_locks%';
表扫描情况 :mysql> show global status like 'handler_read%';
方法二的使用:
 
UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
 
mysqladmin两个参数,status,extended-status
 
shell > mysqladmin -uroot -ppassword variables status
 
其中包含的信息如下:
 
Uptime: 4557887 #mysql运行的秒数
Threads: 1 #连接数
Questions: 1684130 #The number of questions (queries) from clients since the server was started.
Slow queries: 0 #The number of queries that have taken more than long_query_time seconds
Opens: 221872 #The number of tables the server has opened.
Flush tables: 1 #The number of flush-*, refresh, and reload commands the server has executed.
Open tables: 64 #The number of tables that currently are open.
Queries per second avg: 0.369 #从上次运行开始计算,每秒钟平均查询次数
关键的MySQL统计指标
 
当数据库出现查询缓慢或者无法响应查询的情况时,应该怎么办呢?我们可以通过监控与性能及资源利用率相关的指标,来查找出现这个问题的原因,避免依赖数据库性能的相关组件也产生影响。
 
MySQL用户可以接触到的性能指标有几百个,本文介绍四个比较关键常用的指标,查询吞吐量、查询执行性能、连接情况和缓冲池使用情况。
 
查询吞吐量:MySQL内部有一个名为 Questions 的计数器,客户端每发送一个查询语句,其值就会加一,可利用其来衡量查询吞吐量,SHOW GLOBAL STATUS LIKE "Questions";
 
查询执行性能:监控查询延迟的方式有很多,例如通过 MySQL 内置的指标,或者通过查询性能模式。 MySQL 5.6.6 版本开始默认启用,MySQL 的 performance_schema 数据库中的表格存储着服务器事件与查询执行的低水平统计数据。
 
连接情况:MySQL的文档指出,健壮的服务器应该能够处理成百上千的连接数,可通过SHOW VARIABLES LIKE 'max_connections';的形式来查看。
 
缓冲池使用情况:MySQL 默认的存储引擎 InnoDB 使用了一片称为缓冲池的内存区域,用于缓存数据表与索引的数据。如果数据库性能开始下滑,而磁盘 I/O 在不断攀升,扩大缓冲池往往能带来性能回升。
 
感谢各位的阅读!关于“如何查看MySQL性能”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助。

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读