Mysql学习mysql show processlist 显示mysql查询进程
《Mysql学习mysql show processlist 显示mysql查询进程》要点: 2.启动mysql,输入show processlist; 如果有 SUPER 权限,则可以看到全部的线程,否则,只能看到自己发起的线程(这是指,当前对应的MySQL帐户运行的线程). 得到数据形式如下(只截取了三条): mysql> show processlist; +-----+-------------+--------------------+-------+---------+-------+----------------------------------+---------- | Id | User | Host | db | Command | Time| State | Info +-----+-------------+--------------------+-------+---------+-------+----------------------------------+---------- |207|root |192.168.0.20:51718 |mytest | Sleep | 5 | | NULL |208|root |192.168.0.20:51719 |mytest | Sleep | 5 | | NULL |220|root |192.168.0.20:51731 |mytest |Query | 84 | Locked | select bookname,culture,value,type from book where id=001 先简单说一下各列的含义和用途,第一列,id,不用说了吧,一个标识,你要kill一个语句的时候很有用.user列,显示单前用户,如果不是root,这个命令就只显示你权限范围内的sql语句.host列,显示这个语句是从哪个ip的哪个端口上发出的.呵呵,可以用来追踪出问题语句的用户.db列,显示这个进程目前连接的是哪个数据库.command列,显示当前连接的执行的命令,一般就是休眠(sleep),查询(query),连接(connect).time列,此这个状态持续的时间,单位是秒.state列,显示使用当前连接的sql语句的状态,很重要的列,后续会有所有的状态的描述,请注意,state只是语句执行中的某一个状态,一个sql语句,已查询为例,可能需要经过copying to tmp table,Sorting result,Sending data等状态才可以完成,info列,显示这个sql语句 如果你在一个容量大的表中执行增删改字段或执行一个复杂的sql 查询导致mysql线程挂起.可用此命令查看出是哪些sql挂起,用kill命令把他K掉 kill命令使用方法 kill pid 如上例中我们想kill掉id为207的线程则执行 kill 207即可. mysql show processlist命令 详解 MYSQL必读SHOW PROCESSLIST显示哪些线程正在运行.您也可以使用mysqladmin processlist语句得到此信息.如果您有SUPER权限,您可以看到所有线程.否则,您只能看到您自己的线程(也就是,与您正在使用的MySQL账户相关的线程).请参见13.5.5.3节,“KILL语法”.如果您不使用FULL关键词,则只显示每个查询的前100个字符. MYSQL必读本语句报告TCP/IP连接的主机名称(采用host_name:client_port格式),以方便地判定哪个客户端正在做什么. MYSQL必读如果您得到“too many connections”错误信息,并且想要了解正在发生的情况,本语句是非常有用的.MySQL保留一个额外的连接,让拥有SUPER权限的 账户使用,以确保管理员能够随时连接和检查系统(假设您没有把此权限给予所有的用户). MYSQL必读这个命令中最关键的就是state列,mysql列出的状态主要有以下几种: MYSQL必读Checking table 正在检查数据表(这是自动的). MYSQL必读mysql 查看当前连接数 MYSQL必读命令: show processlist;? MYSQL必读命令: show status; MYSQL必读Aborted_clients 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量.? MYSQL必读After create MYSQL必读This occurs when the thread creates a table (including internal temporary tables),at the end of the function that creates the table. This state is used even if the table could not be created due to some error. MYSQL必读Analyzing MYSQL必读The thread is calculating a MyISAM table key distributions (for example,for ANALYZE TABLE). MYSQL必读checking permissions MYSQL必读The thread is checking whether the server has the required privileges to execute the statement. MYSQL必读Checking table MYSQL必读The thread is performing a table check operation. MYSQL必读cleaning up MYSQL必读The thread has processed one command and is preparing to free memory and reset certain state variables. MYSQL必读closing tables MYSQL必读The thread is flushing the changed table data to disk and closing the used tables. This should be a fast operation. If not,you should verify that you do not have a full disk and that the disk is not in very heavy use. MYSQL必读converting HEAP to MyISAM MYSQL必读The thread is converting an internal temporary table from a MEMORY table to an on-disk MyISAM table. MYSQL必读copy to tmp table MYSQL必读The thread is processing an ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are copied into it. MYSQL必读Copying to group table MYSQL必读If a statement has different ORDER BY and GROUP BY criteria,the rows are sorted by group and copied to a temporary table. MYSQL必读Copying to tmp table MYSQL必读The server is copying to a temporary table in memory. MYSQL必读Copying to tmp table on disk MYSQL必读The server is copying to a temporary table on disk. The temporary result set was larger than tmp_table_size and the thread is changing the temporary table from in-memory to disk-based format to save memory. MYSQL必读Creating index MYSQL必读The thread is processing ALTER TABLE ... ENABLE KEYS for a MyISAM table. MYSQL必读Creating sort index MYSQL必读The thread is processing a SELECT that is resolved using an internal temporary table. MYSQL必读creating table MYSQL必读The thread is creating a table. This includes creation of temporary tables. MYSQL必读Creating tmp table MYSQL必读The thread is creating a temporary table in memory or on disk. If the table is created in memory but later is converted to an on-disk table,the state during that operation will be Copying to tmp table on disk. MYSQL必读deleting from main table MYSQL必读The server is executing the first part of a multiple-table delete. It is deleting only from the first table,and saving columns and offsets to be used for deleting from the other (reference) tables. MYSQL必读deleting from reference tables MYSQL必读The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables. MYSQL必读discard_or_import_tablespace MYSQL必读The thread is processing an ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE statement. MYSQL必读end MYSQL必读This occurs at the end but before the cleanup of ALTER TABLE,CREATE VIEW,DELETE,INSERT,SELECT,or UPDATE statements. MYSQL必读executing MYSQL必读The thread has begun executing a statement. MYSQL必读Execution of init_command MYSQL必读The thread is executing statements in the value of the init_command system variable. MYSQL必读freeing items MYSQL必读The thread has executed a command. This state is usually followed by cleaning up. MYSQL必读Flushing tables MYSQL必读The thread is executing FLUSH TABLES and is waiting for all threads to close their tables. MYSQL必读FULLTEXT initialization MYSQL必读The server is preparing to perform a natural-language full-text search. MYSQL必读init MYSQL必读This occurs before the initialization of ALTER TABLE,or UPDATE statements. MYSQL必读Killed MYSQL必读Someone has sent a KILL statement to the thread and it should abort next time it checks the kill flag. The flag is checked in each major loop in MySQL,but in some cases it might still take a short time for the thread to die. If the thread is locked by some other thread,the kill takes effect as soon as the other thread releases its lock. MYSQL必读Locked MYSQL必读The query is locked by another query. MYSQL必读logging slow query MYSQL必读The thread is writing a statement to the slow-query log. MYSQL必读NULL MYSQL必读This state is used for the SHOW PROCESSLIST state. MYSQL必读login MYSQL必读The initial state for a connection thread until the client has been authenticated successfully. MYSQL必读Opening tables,Opening table MYSQL必读The thread is trying to open a table. This is should be very fast procedure,unless something prevents opening. For example,an ALTER TABLE or a LOCK TABLE statement can prevent opening a table until the statement is finished. MYSQL必读preparing MYSQL必读This state occurs during query optimization. MYSQL必读Purging old relay logs MYSQL必读The thread is removing unneeded relay log files. MYSQL必读query end MYSQL必读This state occurs after processing a query but before the freeing items state. MYSQL必读Reading from net MYSQL必读The server is reading a packet from the network. MYSQL必读Removing duplicates MYSQL必读The query was using SELECT DISTINCT in such a way that MySQL could not optimize away the distinct operation at an early stage. Because of this,MySQL requires an extra stage to remove all duplicated rows before sending the result to the client. MYSQL必读removing tmp table MYSQL必读The thread is removing an internal temporary table after processing a SELECT statement. This state is not used if no temporary table was created. MYSQL必读rename MYSQL必读The thread is renaming a table. MYSQL必读rename result table MYSQL必读The thread is processing an ALTER TABLE statement,has created the new table,and is renaming it to replace the original table. MYSQL必读Reopen tables MYSQL必读The thread got a lock for the table,but noticed after getting the lock that the underlying table structure changed. It has freed the lock,closed the table,and is trying to reopen it. MYSQL必读Repair by sorting MYSQL必读The repair code is using a sort to create indexes. MYSQL必读Repair done MYSQL必读The thread has completed a multi-threaded repair for a MyISAM table. MYSQL必读Repair with keycache MYSQL必读The repair code is using creating keys one by one through the key cache. This is much slower than Repair by sorting. MYSQL必读Rolling back MYSQL必读The thread is rolling back a transaction. MYSQL必读Saving state MYSQL必读For MyISAM table operations such as repair or analysis,the thread is saving the new table state to the .MYI file header. State includes information such as number of rows,the AUTO_INCREMENT counter,and key distributions. MYSQL必读Searching rows for update MYSQL必读The thread is doing a first phase to find all matching rows before updating them. This has to be done if the UPDATE is changing the index that is used to find the involved rows. MYSQL必读Sending data MYSQL必读The thread is processing rows for a SELECT statement and also is sending data to the client. MYSQL必读setup MYSQL必读The thread is beginning an ALTER TABLE operation. MYSQL必读Sorting for group MYSQL必读The thread is doing a sort to satisfy a GROUP BY. MYSQL必读Sorting for order MYSQL必读The thread is doing a sort to satisfy a ORDER BY. MYSQL必读Sorting index MYSQL必读The thread is sorting index pages for more efficient access during a MyISAM table optimization operation. MYSQL必读Sorting result MYSQL必读For a SELECT statement,this is similar to Creating sort index,but for nontemporary tables. MYSQL必读statistics MYSQL必读The server is calculating statistics to develop a query execution plan. MYSQL必读System lock MYSQL必读The thread is going to request or is waiting for an internal or external system lock for the table. If this state is being caused by requests for external locks and you are not using multiple mysqld servers that are accessing the same tables,you can disable external system locks with the --skip-external-locking option. However,external locking is disabled by default,so it is likely that this option will have no effect. For SHOW PROFILE,this state means the thread is requesting the lock (not waiting for it). MYSQL必读Table lock MYSQL必读The next thread state after System lock. The thread has acquired an external lock and is going to request an internal table lock. MYSQL必读Updating MYSQL必读The thread is searching for rows to update and is updating them. MYSQL必读updating main table MYSQL必读The server is executing the first part of a multiple-table update. It is updating only the first table,and saving columns and offsets to be used for updating the other (reference) tables. MYSQL必读updating reference tables MYSQL必读The server is executing the second part of a multiple-table update and updating the matched rows from the other tables. MYSQL必读User lock MYSQL必读The thread is going to request or is waiting for an advisory lock requested with a GET_LOCK() call. For SHOW PROFILE,this state means the thread is requesting the lock (not waiting for it). MYSQL必读Waiting for tables,Waiting for table MYSQL必读The thread got a notification that the underlying structure for a table has changed and it needs to reopen the table to get the new structure. However,to reopen the table,it must wait until all other threads have closed the table in question. MYSQL必读This notification takes place if another thread has used FLUSH TABLES or one of the following statements on the table in question: FLUSH TABLES tbl_name,or OPTIMIZE TABLE. MYSQL必读Waiting on cond MYSQL必读A generic state in which the thread is waiting for a condition to become true. No specific state information is available. MYSQL必读Writing to net MYSQL必读The server is writing a packet to the network. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- MYSQL数据库mysql 5.7.17 winx64.zip安装配置方法图文教程
- MySQL设置表的字段值自动增加
- mysql – Sequelize TypeError build.save不是一个函数
- Mysql应用Mysql - 性能优化之子查询
- pyodbc MySQL Windows:找不到数据源名称,也没有指定默认驱
- Mysql应用浅析mysql交互式连接&非交互式连接
- MYSQL教程mysql正确安全清空在线慢查询日志slow log的流程分
- Mysql应用MySQL skip-character-set-client-handshake导致的
- MYSQL数据库Linux下编译安装Mysql 5.5的简单步骤
- Mysql入门mysql数据库常用命令(新手必备)