show processlist结果筛选(一)

2014-11-24 14:01:18 · 作者: · 浏览: 1
show processlist结果筛选
在MySQL里面
show variables where variable_name like '%auto%'
这条语句可以正常执行,但是
show processlist where host like '%192%'
就会报错了:
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘where host like ‘%10%” at line 1
show processlist 直接是可以执行的,但是不能进行筛选,着实让人头疼,同样的结构variables可以,但为什么就processlist就是不行呢?究其原因原来MySQL有此BUG:
Description:
SHOW PROCESSLIST lists to many lines when you have 250 or even 1000 users connect to you
system.
How to repeat:
n.a.
Suggested fix:
It would be nice having something like
SHOW PROCESSLIST LIKE ‘user|host|…’
to reduce the output to the relevant informations.
Much more nice would be having something like:
SELECT user, host, time, command, time
FROM [mysql|information_schema].processlist
WHERE user = 'me' and state IS NOT NULL;
所以processlist的show方式是不能使用过滤查找,可能源自MySQL的内部安全机制吧,show是用来查看MySQL内部运行数据,其实processlist就是
information_schema 数据库中的一张表,那么通过查表的方式肯定是可以的了:
SELECT user, host, time, command, time
FROM [ mysql|information_schema].processlist
WHERE user = 'me' and state IS NOT NULL;
另附MySQL Show命令的一些详解,供查阅:
show tables或show tables from database_name或show database_name.tables;
解释:显示当前数据库中所有表的名称
show databases;
解释:显示mysql中所有数据库的名称
show processlist;
解释:显示 系统中正在运行的所有进程,也就是当前正在执行的查询。大多数用户可以查看
他们自己的进程,但是如果他们拥有process权限,就可以查看所有人的进程,包括密码。
show table status;
解释:显示当前使用或者指定的database中的每个表的信息。信息包括表类型和表的最新更新时间
show columns from table_name from database_name; 或show columns from database_name.table_name;或show fields;
解释:显示表中列名称(和 desc table_name 命令的效果是一样的)
show grants for user_name@localhost;
解释:显示一个用户的权限,显示结果类似于grant 命令
show index from table_name;或show keys;
解释:显示表的索引
show status;
解释:显示一些系统特定资源的信息,例如,正在运行的线程数量
show variables;
解释:显示系统变量的名称和值
show privileges;
解释:显示服务器所支持的不同权限
show create database database_name;
解释:显示创建指定数据库的SQL语句
show create table table_name;
解释:显示创建指定数据表的SQL语句
show engies;
解释:显示安装以后可用的存储引擎和默认引擎。
show innodb status;
解释:显示innoDB存储引擎的状态
show logs;
解释:显示BDB存储引擎的日志
show warnings;
解释:显示最后一个执行的语句所产生的错误、警告和通知
show errors;
解释:只显示最后一个执行语句所产生的错误
上面的大部分命令都可以用like,比如 show table like ‘%abce%’ 。
附:
show status 结果说明
含义
Name 表名
Type 表的类型 (ISAM,MyISAM或HEAP)
Row_format 行存储格式 (固定, 动态, 或压缩)
Rows 行数量
Avg_row_length 平均行长度
Data_length 数据文件的长度
Max_data_length 数据文件的最大长度
Index_length 索引文件的长度
Data_free 已分配但未使用了字节数
Auto_increment 下一个 autoincrement(自动加1)值
Create_time 表被创造的时间
Update_time 数据文件最后更新的时间
Check_time 最后对表运行一个检查的时间
Create_options 与CREATE TABLE一起使用的额外选项
Comment 当创造表时,使用的注释 (或为什么MySQL不能存取表信息的一些信息)。
show index 结果说明:
含义
Table 表名
Non_unique 0,如果索引不能包含重复。
Key_name 索引名
Seq_in_index 索引中的列顺序号, 从 1 开始。
Column_name 列名。
Collation 列怎样在索引中被排序。在MySQL中,这可以有值A(升序) 或NULL(不排序)。
Cardinality 索引中唯一值的数量。这可通过运行isamchk -a更改.
Sub_part 如果列只是部分被索引,索引字符的数量。NULL,如果整个键被索引。
show variables 结果说明:
Aborted_clients 由于客户没有正确