mysql -e加v簡化代碼 用 mysql -e 生成結果導入指定文件時: ● 若要同時顯示語句本身:-v ● 若要增加查詢結果行數:-vv ● 若要增加執行時間:-vvv 在一些監控腳本中可以用來簡化代碼 [plain] ㈠ 不帶 v 測試: [mysql@even ~]$ mysql -uroot -poracle -e "SELECT VERSION();SELECT NOW()" > /home/mysql/test.sql [mysql@even ~]$ cat /home/mysql/test.sql VERSION() 5.5.16-log NOW() 2013-05-08 18:06:35 ㈡ 帶一個 v 測試: [mysql@even ~]$ mysql -uroot -poracle -e "SELECT VERSION();SELECT NOW()" -v > /home/mysql/test02.sql [mysql@even ~]$ cat /home/mysql/test02.sql -------------- SELECT VERSION() -------------- VERSION() 5.5.16-log -------------- SELECT NOW() -------------- NOW() 2013-05-08 18:08:40 ㈢ 帶兩個 v 測試: [mysql@even ~]$ mysql -uroot -poracle -e "SELECT VERSION();SELECT NOW()" -vv > /home/mysql/test03.sql [mysql@even ~]$ cat /home/mysql/test03.sql -------------- SELECT VERSION() -------------- VERSION() 5.5.16-log 1 row in set -------------- SELECT NOW() -------------- NOW() 2013-05-08 18:14:05 1 row in set Bye ㈢ 帶三個 v 測試: [mysql@even ~]$ mysql -uroot -poracle -e "SELECT VERSION();SELECT NOW()" -vvv > /home/mysql/test04.sql [mysql@even ~]$ cat /home/mysql/test04.sql -------------- SELECT VERSION() -------------- +------------+ | VERSION() | +------------+ | 5.5.16-log | +------------+ 1 row in set (0.00 sec) -------------- SELECT NOW() -------------- +---------------------+ | NOW() | +---------------------+ | 2013-05-08 18:14:49 | +---------------------+ 1 row in set (0.00 sec) Bye