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执行

 

相关文章

在Linux系统中,设置ARP防火墙可以通过多种方法实现,包括使...
在Linux环境下,使用Jack2进行编译时,可以采取以下策略来提...
`getid`命令在Linux系统中用于获取当前进程的有效用户ID(EU...
在Linux环境下,codesign工具用于对代码进行签名,以确保其完...
Linux中的`tr`命令,其英文全称是“transform”,即转换的意...
Linux中的ARP防火墙是一种用于防止ARP欺骗攻击的安全措施,它...