bitsCN.com
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 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量。
Aborted_connects 尝试已经失败的MySQL服务器的连接的次数。
Connections 试图连接MySQL服务器的次数。
Created_tmp_tables 当执行语句时,已经被创造了的隐含临时表的数量。
Delayed_insert_threads 正在使用的延迟插入处理器线程的数量。
Delayed_writes 用INSERT DELAYED写入的行数。
Delayed_errors 用INSERT DELAYED写入的发生某些错误(可能重复键值)的行数。
Flush_commands 执行FLUSH命令的次数。
Handler_delete 请求从一张表中删除行的次数。
Handler_read_first 请求读入表中第一行的次数。
Handler_read_key 请求数字基于键读行。
Handler_read_next 请求读入基于一个键的一行的次数。
Handler_read_rnd 请求读入基于一个固定位置的一行的次数。
Handler_update 请求更新表中一行的次数。
Handler_write 请求向表中插入一行的次数。
Key_blocks_used 用于关键字缓存的块的数量。
Key_read_requests 请求从缓存读入一个键值的次数。
Key_reads 从磁盘物理读入一个键值的次数。
Key_write_requests 请求将一个关键字块写入缓存次数。
Key_writes 将一个键值块物理写入磁盘的次数。
Max_used_connections 同时使用的连接的最大数目。
Not_flushed_key_blocks 在键缓存中已经改变但是还没被清空到磁盘上的键块。
Not_flushed_delayed_rows 在INSERT DELAY队列中等待写入的行的数量。
Open_tables 打开表的数量。
Open_files 打开文件的数量。
Open_streams 打开流的数量(主要用于日志记载)
Opened_tables 已经打开的表的数量。
Questions 发往服务器的查询的数量。
Slow_queries 要花超过long_query_time时间的查询数量。
Threads_connected 当前打开的连接的数量。
Threads_running 不在睡眠的线程数量。
Uptime 服务器工作了多少秒。
关于上面的一些注释:
如果Opened_tables太大,那么你的table_cache变量可能太小。
如果key_reads太大,那么你的key_cache可能太小。缓存命中率可以用key_reads/key_read_requests计算。
如果Handler_read_rnd太大,那么你很可能有大量的查询需要MySQL扫描整个表或你有没正确使用键值的联结(join)。
bitsCN.com

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.