mysql -e加v简化代码_MySQL
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
bitsCN.com
上一篇: Centos升级php mysql
下一篇: QQ的账号登录及api操作