[20131211]mysql pager定義=vim.txt

lfree發表於2013-12-11
[20131211]mysql pager定義=vim.txt

今天看廠家除錯安全裝置,發現後臺資料庫使用mysql。我發現他select * from 後,顯示是的vim的編輯介面,感覺很有意思,
自己一點也不熟悉mysql,不過我在公司使用cacti監控各種裝置以及伺服器,自己也測試看看。

# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14542484 to server version: 4.1.12

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> help

For the complete MySQL Manual online, visit:
   http://www.mysql.com/documentation

For info on technical support from MySQL developers, visit:
   http://www.mysql.com/support

For info on MySQL books, utilities, consultants, etc., visit:
   http://www.mysql.com/portal

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set query delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute a SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.

For server side help, type 'help contents'

--很明顯修改pager引數就可以實現。

我執行如下:
mysql> pager vim
mysql> select * from cdef;

--不行。修改如下:

mysql> pager vim -
mysql> select * from cdef;

--ok通過!很明顯這個結果僅僅read only。這樣設定vim只讀
mysql> pager vim -R -c "set nowrap" -

--可惜oracle沒有這個特性。如果要永久有效,加入/etc/my.cnf檔案中加入如下:
[mysql]
pager=vim -R -c "set nowrap syntax=txt" -

--google 查詢mysql pager 還可以發現許多有趣的例子。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1062965/,如需轉載,請註明出處,否則將追究法律責任。

[20131211]mysql pager定義=vim.txt
請登入後發表評論 登入
全部評論

相關文章