---
title: "mysql下的 show/desc/explain"
author: "tmuffamd"
date: "2015-11-24T14:42:59Z"
tags: []
categories: ["数据库"]
slug: "mysql-show-desc-explain"
draft: false
lastmod: "2015-11-24T15:00:25Z"
id: 2258820
url: "https://tmuffamd.iteye.com/blog/2258820"
---

1 性能瓶颈定位Show命令

我们可以通过show命令查看MySQL状态及变量，找到系统的瓶颈：

Mysql&gt; show status ——显示状态信息（扩展show status like ‘XXX’）

Mysql&gt; show variables ——显示系统变量（扩展show variables like ‘XXX’）

Mysql&gt; show innodb status ——显示InnoDB存储引擎的状态

Mysql&gt; show processlist ——查看当前SQL执行，包括执行状态、是否锁表等

Shell&gt; mysqladmin variables -u username -p password——显示系统变量

Shell&gt; mysqladmin extended-status -u username -p password——显示状态信息

查看状态变量及帮助：

Shell&gt; mysqld –verbose –help \[|more #逐行显示]

 

 

 

1\. 查看配置

       show variable;

       2.查看目前处理的列表；

       show processlist;

       3.看看有哪些存储过程

       show procedure status;

       4.查看一条命令的执行方案

       explain select * fromt t\_your\_tabe;

       如果是分区表

      explain partitions select * from t\_your\_table;

      5. 查看表的信息

      desc t\_your\_table;

      6.查看表的创建

      show create table t\_your\_table;

      7.查看存储过程的创建

      show create procedure p\_your\_procedure

      8.查看所有支持的字符集

      use information\_schema;

     select * from character\_sets;

     实际上很多信息在mysql和information\_schema可以查到

     9. 索引

     show index from t\_your\_table;

    10. 主服务器

    show master status;

    11. 从服务器

    show  slave status;

    12. 查看日志 

    show binary logs;

    13 查看状态

    show status;

    14 查看user权限

    show grant for u\_user\_name

    15. 查看服务器支持的权限

    show  privileges；