微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mysql中执行 linux shell命令本地shell执行

MysqL> help
For information about MysqL products and services,visit:
   http://www.MysqL.com/
For developer information,including the MysqL Reference Manual,visit:
   http://dev.MysqL.com/
To buy MysqL Network Support,training,or other products,visit:
   https://shop.MysqL.com/

List of all MysqL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement 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 an 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.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
Nowarning (\w) Don't show warnings after every statement.

从帮助信息可以看到 system 命令可以执行 还有 \! 也是同样的效果

测试一下:

MysqL> system ls
cjjcpptest  fork  main.cpp

MysqL> \! ls
cjjcpptest  fork  main.cpp

MysqL> \! ping localhost;
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.000 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.000 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.000 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.000 ms
64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.000 ms

--- localhost ping statistics ---

成功执行shell命令。注意是 本地shell执行

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐