一、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;
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)]
Linux之高階命令
centos和redhat suse系列 rpm qa kernel或rpm qa grep i kerneldebian和ubuntu系列 dpkg list grep linux image sysctl命令的配置檔案是 etc sysctl.conf,可以 1.使用sysctl工具修改核心引數...
MySQL效能優化之高階篇
4.1 索引是什麼,建立索引的原因 索引用於快速找出在某個列中有一特定值的行,不使用索引mysql必須從第一條記錄開始讀完整個表,直到找出相關的行,表越大查詢資料所花費的時間就越多,如果表中查詢的列有乙個索引,mysql能夠快速到達乙個位置去搜尋資料檔案,而不必檢視所有資料,那麼將會節省很大一部分時...
PHP程式設計之高階技巧 利用Mysql函式
儘管php為我們提供了很多函式,但有些東西處理起來還是不很方便。譬如php提供的日期時間函式就很有限。mysql為我們提供了不少此類的函式。是否可以利用mysql函式來處理php程式呢?筆者做了以下的嘗試。data time 1998 12 31 23 59 59 connect id mysql ...