Home  >  Article  >  Database  >  Mysql analysis-summary of commonly used analysis statements

Mysql analysis-summary of commonly used analysis statements

黄舟
黄舟Original
2017-03-02 16:03:461531browse


We sometimes encounter errors or slowdowns in the mysql database. At this time, we need to take a look at some basic situations

A bad SQL statement may make your entire program very slow. Is it because there are too many connections? Is there a problem with the table structure? The index of the table is not added? . .

Below are some mysql analysis statements that I commonly use, make a record.

##Serial numberStatementFunction1show PROCESSLIST;Displays all processes running in the system, that is, the query currently being executed. 2show status [ like "%Thread%]";Display some system-specific resource information, For example, the number of running threads. 3show variables [like '%profili%'];Display the names and values ​​of system variables. It is a system parameter that can be adjusted statically (my.cnf or statement adjustment) 4desc table_name;Analysis Table structure5show create table table_name;View table creation statement6show index from table_name;View the index of the table7show profiles;View the status of executed statements8explain sql; Analyze statement execution status


1.mysql> show PROCESSLIST;


##

2.mysql> show status;


#Display some information about all system resources.

3.mysql> show status like "Threads%";


Displays information about some system-specific resources, for example, running Number of threads.

4.mysql>  show variables like '%profili%';


##Displays the variable values ​​related to the system profile. [

Mysql analysis-profile detailed explanation]

mysql> show variables like "%query_cache%";


5.mysql> show index from table_name;

##Check the index status of a table

mysql> select database(); //显示当前选中数据库
mysql> show databases; //显示数据库列表
mysql> use database_name; //选择使用数据库
mysql> select version(); //显示mysql版本
mysql> reset query cache; //清理查询缓存

That’s it Mysql analysis - a summary of commonly used analysis statements. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Most users can view their own processes, but if they have process permissions,
they can view everyone's processes, including passwords.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn