时间:2021-07-01 10:21:17 帮助过:41人阅读
1) pager pager真是一个很神奇的东西,它可以控制mysql的输出。默认值是stdout,直接输出。艾,貌似讲不清楚啊,还是看几个例子吧: mysql SELECT mobile FROM profile WHERE mobile!='';+-------------+| mobile |+-------------+| 13719001986 || 12321423
mysql> SELECT mobile FROM profile WHERE mobile!=''; +-------------+ | mobile | +-------------+ | 13719001986 | | 123214234 | +-------------+ 2 ROWS IN SET (0.00 sec) ? mysql> mysql> pager grep "137" PAGER SET TO 'grep "137"' mysql> mysql> SELECT mobile FROM profile WHERE mobile!=''; | 13719001986 | 2 ROWS IN SET (0.00 sec) ? mysql> pager DEFAULT pager wasn't set, using stdout |
pager cat > /dev/null再比如,看一下processlist里面Sleep的线程有多少,可以使用
pager grep Sleep | wc -l
mysql> tee /tmp/h.log Logging TO file '/tmp/h.log' mysql> mysql> mysql> SHOW engine innodb STATUS; ......... mysql> exit |
mysql> prompt \r:\m:\s\P>\_ PROMPT SET TO '\r:\m:\s\P>\_' 11:30:10am> 11:30:11am> 11:30:11am> 11:30:12am> 11:30:12am> 11:30:12am> 11:30:12am> |
mysql> mysql> mysql> SELECT now(); +---------------------+ | now() | +---------------------+ | 2012-12-25 15:33:16 | +---------------------+ 1 ROW IN SET (0.00 sec) ? mysql> 不要按ctrl+d了, 换成Ctrl+z , 暂停任务。 [1]+ Stopped /home/mysql/bin/mysql -uroot -p [MODIFY@www 8p]$ [MODIFY@www 8p]$ [MODIFY@www 8p]$ 需要用到mysql的时候, 输入fg回车: [MODIFY@www 8p]$ fg /home/mysql/bin/mysql -uroot -p mysql> mysql> |
[root@www ~]# /home/mysql/bin/mysql -uroot -p -H -e "select host from mysql.user"; Enter password: hostlocalhostlocalhostlocalhostlocalhostlocalhostlocalhost[root@www ~]# |
[root@www ~]# /home/mysql/bin/mysql -uroot -p -e "select count(*) from shipincon.share where add_time >= current_date()"; +----------+ | COUNT(*) | +----------+ | 850 | +----------+ ? [root@www ~]# /home/mysql/bin/mysql --silent --skip-line-numbers --skip-column-names -uroot -p -e "select count(*) from shipincon.share where add_time >= current_date()"; 850 |
mysql> help string functions; You asked FOR help about help category: "String Functions" FOR more information, TYPE 'help ', WHERE IS one OF the following topics: ASCII BIN BINARY OPERATOR BIT_LENGTH CAST CHAR FUNCTION CHARACTER_LENGTH CHAR_LENGTH CONCAT CONCAT_WS CONVERT ELT EXPORT_SET EXTRACTVALUE FIELD FIND_IN_SET FORMAT HEX ........ ? mysql> help instr; Name: 'INSTR' Description: Syntax: INSTR(str,substr) ? RETURNS the POSITION OF the FIRST occurrence OF SUBSTRING substr IN string str. This IS the same AS the two-argument form OF LOCATE(), EXCEPT that the ORDER OF the arguments IS reversed. ? URL: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html ? Examples: mysql> SELECT INSTR('foobarbar', 'bar'); -> 4 mysql> SELECT INSTR('xbar', 'foobar'); -> 0 |
原文地址:Mysql命令行技巧汇总, 感谢原作者分享。