1.通过show status命令了解各种sql执行的频率。
格式:mysql>show [session|global] status;
其中:session(默认)表示当前连接
global 表示自数据库启动至今
相关操作:
mysql>show status;
mysql>show global status;
mysql>show status like 'Com_%';
mysql>show global status like 'Com_%';
截图:展示数据库的各种状态
一般查看以Com_开头的
查看增删改查的总数
show global status like 'Com_insert';
show global status like 'Com_update';
show global status like 'Com_select';
show global status like 'Com_delete';
截图:
查看Innodb引擎表受影响的行数:
mysql> show global status like 'innodb_rows%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Innodb_rows_deleted | 0 |
| Innodb_rows_inserted | 12 |
| Innodb_rows_read | 78 |
| Innodb_rows_updated | 0 |
+----------------------+-------+
4 rows in set (0.00 sec)
查看连接总次数
mysql> show global status like 'connections';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 2865 |
+---------------+-------+
1 row in set (0.00 sec)
服务器已经工作的秒数:
mysql> show global status like 'uptime';
+---------------+--------+
| Variable_name | Value |
+---------------+--------+
| Uptime | 515199 |
+---------------+--------+
1 row in set (0.00 sec)
查询慢查询的总次数:
mysql> show global status like 'slow_queries';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries | 0 |
+---------------+-------+
1 row in set (0.00 sec)
本文介绍如何使用MySQL的show status命令来查询数据库的状态变量,包括SQL执行频率、连接次数、服务器运行时间等,帮助理解数据库性能。
382

被折叠的 条评论
为什么被折叠?



