使用mysql命令行时, 输出太多的东西, 看不到就很悲剧了。在shell中可以使用管道或是直接用more, 但是mysql命令行里怎么办呢?

mysql3306.sock [(none)]> \h

pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. 


1.

# 设置less阅读模式

mysql3306.sock [bailidb]> pager less;

PAGER set to 'less'


# 使用less阅读模式查看InnoDB Status信息

mysql3306.sock [bailidb]> show engine innodb status\G;

/TRANSACTION => 搜索

n => 下一个

Home键 ↑ Top

End键 ↓ bottom

q => 退出

空格 => 下一页


# 取消pager设置

mysql3306.sock [bailidb]> nopager; \n

PAGER set to stdout


2. 

# 处理大量的数据集的时候, 如果只想关心结果(比如说花费的时间)

mysql3306.sock [bailidb]> pager cat > /dev/null;

PAGER set to 'cat > /dev/null'


mysql3306.sock [bailidb]> show tables;

5 rows in set (0.00 sec)


mysql3306.sock [bailidb]> select * from t2;

1 row in set (0.00 sec)


mysql3306.sock [bailidb]> nopager; \n

PAGER set to stdout


3.

# 在进行SQL调优, 有大量的结果产生, 可以通过checksum去比较每次调整后的SQL语句所产生的结果是否是相同的

mysql3306.sock [bailidb]> pager md5sum;

mysql3306.sock [bailidb]> select * from t1;

3cd934ef8bc8faa65b917a9fb8c15847  -

1 row in set (0.00 sec)


mysql3306.sock [bailidb]> select * from t2;

6aff230e5e7bcf6af5bbceda0256288a  -


mysql3306.sock [bailidb]> nopager; \n

PAGER set to stdout 


4. 

# show processlist 检查

mysql3306.sock [(none)]> pager grep Sleep;

PAGER set to 'grep Sleep'

mysql3306.sock [(none)]> show processlist;

|  4 | root | localhost | NULL | Sleep   |   53 |          | NULL             |

mysql3306.sock [bailidb]> nopager; \n

PAGER set to stdout


学习自该篇文章,自己做了验证

http://www.coin163.com/it/6991542063249997190/pager-mysql