mysql的高级应用_MySQL之高级命令使用介绍

一、mysql之高级命令Pager使用

分屏显示内容:

root@localhost [(none)]>pager more

PAGER set to 'more'

root@localhost [(none)]>select * from testdb.zx_scores;

root@localhost [(none)]>pager less

PAGER set to 'less'

root@localhost [(none)]>

root@localhost [(none)]>select * from testdb.zx_scores;

结果中搜索:

root@localhost [(none)]>pager grep Sleep|wc -l;

PAGER set to 'grep Sleep|wc -l'

root@localhost [(none)]>show full processlist;

0

7 rows in set (0.00 sec)

root@localhost [(none)]>

不显示查询出来结果:

root@localhost [(none)]>pager cat >>/dev/null

PAGER set to 'cat >>/dev/null'

root@localhost [(none)]>select * from information_schema.tables;

282 rows in set, 48 warnings (0.04 sec)

root@localhost [(none)]>select * from testdb.zx_scores;

33 rows in set (0.01 sec)

root@localhost [(none)]>nopager

PAGER set to stdout

root@localhost [(none)]>select count(*) from testdb.zx_scores;

+----------+

| count(*) |

+----------+

| 33 |

+----------+

1 row in set (0.00 sec)

结果用md5sum比较:

root@localhost [(none)]>pager md5sum

PAGER set to 'md5sum'

root@localhost [(none)]>select * from information_schema.tables;

f3e004ca08069e1b4536d175f8373583 -

282 rows in set, 48 warnings (0.05 sec)

恢复 pager:

root@localhost [(none)]>pager 或是 root@localhost [(none)]>nopager

二、记录MySQL输入的命令及结果

使用tee命令或是在配置文件配置,演示如下:

root@localhost [(none)]>tee /tmp/mysql.log

Logging to file '/tmp/mysql.log'

root@localhost [(none)]>select count(*) from testdb.zx_scores;

+----------+

| count(*) |

+----------+

| 33 |

+----------+

1 row in set (0.00 sec)

[root@localhost ~]# tailf /tmp/mysql.log

root@localhost [(none)]>select count(*) from testdb.zx_scores;

+----------+

| count(*) |

+----------+

| 33 |

+----------+

1 row in set (0.00 sec)

root@localhost [(none)]>select count(*) from testdb.zx_scores;

+----------+

| count(*) |

+----------+

| 33 |

+----------+

1 row in set (0.00 sec)

另外也可以通过在配置文件中,加如下这个配置 :

[mysql]

tee=/tmp/mysql.log

再次登录即可 (前提这个配置文件是可以被mysql读到的)

三、MySQL调用系统命令

该功能只能Linux平台支持,利用system后面跟命令调用

root@localhost [(none)]>system ls

root@localhost [(none)]>system top

root@localhost [(none)]>system ps -eostart,cmd,pid|grep mysqld

Nov 26 /usr/local/mysql/bin/mysqld 2798

18:06:15 grep mysqld 9247

root@localhost [(none)]>

root@localhost [(none)]>system ps -ef|grep mysqld

root 1023 1 0 11月26 ? 00:00:00 /bin/sh /usr/local/mysql//bin/mysqld_safe --datadir=/data/mysql/data --pid-file=/data/mysql/data/localhost.localdomain.pid

mysql 2798 1023 0 11月26 ? 00:07:41 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql/ --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql//lib/plugin --user=mysql --log-error=/data/mysql/logs/error.log --open-files-limit=65536 --pid-file=/data/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306

root 9248 9194 0 18:06 pts/0 00:00:00 sh -c ps -ef|grep mysqld

root 9250 9248 0 18:06 pts/0 00:00:00 grep mysqld

root@localhost [(none)]>

欢迎大家一起交流学习,如果有其他的高级的命令,希望大家可以分享下,一起探讨,共同进步

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值