In oracle database, command "host" can be used to run bash command from database command window. Is there a equivalent command as "host" in mySql?
在oracle数据库中,命令“host”可用于从数据库命令窗口运行bash命令。在mySql中是否有与“host”等效的命令?
5 个解决方案
#1
13
You can use the system
command.
您可以使用system命令。
system command, \! command
系统命令,\!命令
Executes the given command using your default command interpreter.
使用默认命令解释程序执行给定命令。
The system command works only in Unix.
system命令仅适用于Unix。
Example:
system ls -l
#2
2
I'm running version 5.0.95-log on Linux. Prefacing the command either by "system" or by "!" works for the "pwd" and the "ls -l" commands. If I try to change directory using, e.g.
我在Linux上运行5.0.95-log版本。通过“system”或“!”来命令命令。适用于“pwd”和“ls -l”命令。如果我尝试使用更改目录,例如
mysql> system cd /home/mydir
mysql> system cd / home / mydir
the command seems to be accepted. But this apparently does nothing, as following "pwd" and "ls -l" commands indicate that I am still in the same directory. So it appears that there is a stub of limited functionality built in for this, but that we do not actually have full access to the system shell.
该命令似乎被接受了。但这显然没有做任何事情,因为跟随“pwd”和“ls -l”命令表明我仍然在同一目录中。因此,似乎内置了一个功能有限的存根,但我们实际上并没有对系统shell的完全访问权限。
#3
1
It's actually possible to execute shell commands on the server that mysqld is running though a client connection (rather than executing commands on the client machine locally) by using MySQL Proxy (scroll down to the "Shell commands from MySQL client" section ).
实际上,通过使用MySQL代理(通过向下滚动到“来自MySQL客户端的Shell命令”部分),可以在mysqld通过客户端连接运行的服务器上执行shell命令(而不是在本地客户端计算机上执行命令)。
#4
0
As an additional tweak, on most "'nix" systems you can actually do something like this:
作为一个额外的调整,在大多数“'nix”系统上你可以实际做这样的事情:
mysql> system bash
And have the entire terminal at your disposal. This is particularly effective if you're doing code work in the terminal that interfaces with MySQL; from the shell, typing "exit" will take you back into the MySQL monitor/client, so you can go back and forth quite easily.
并为您提供整个终端。如果您在与MySQL接口的终端中进行代码工作,这将特别有效;从shell中输入“exit”会将你带回MySQL监视器/客户端,这样你就可以很容易地来回走动。
Obviously, other shells ("mysql> system tcsh") would work as well.
显然,其他shell(“mysql> system tcsh”)也可以正常工作。
#5
-1
In a linux machine you should be able to use the following example
在linux机器中,您应该能够使用以下示例
- ! clear - to clear the screen
- ! ls - to list files in the current working directory
- Basically you should be able to run any command or script using that syntax
!清除 - 清除屏幕
! ls - 列出当前工作目录中的文件
基本上,您应该能够使用该语法运行任何命令或脚本
NB: Add a back slash before !
注意:之前添加反斜杠!
#1
13
You can use the system
command.
您可以使用system命令。
system command, \! command
系统命令,\!命令
Executes the given command using your default command interpreter.
使用默认命令解释程序执行给定命令。
The system command works only in Unix.
system命令仅适用于Unix。
Example:
system ls -l
#2
2
I'm running version 5.0.95-log on Linux. Prefacing the command either by "system" or by "!" works for the "pwd" and the "ls -l" commands. If I try to change directory using, e.g.
我在Linux上运行5.0.95-log版本。通过“system”或“!”来命令命令。适用于“pwd”和“ls -l”命令。如果我尝试使用更改目录,例如
mysql> system cd /home/mydir
mysql> system cd / home / mydir
the command seems to be accepted. But this apparently does nothing, as following "pwd" and "ls -l" commands indicate that I am still in the same directory. So it appears that there is a stub of limited functionality built in for this, but that we do not actually have full access to the system shell.
该命令似乎被接受了。但这显然没有做任何事情,因为跟随“pwd”和“ls -l”命令表明我仍然在同一目录中。因此,似乎内置了一个功能有限的存根,但我们实际上并没有对系统shell的完全访问权限。
#3
1
It's actually possible to execute shell commands on the server that mysqld is running though a client connection (rather than executing commands on the client machine locally) by using MySQL Proxy (scroll down to the "Shell commands from MySQL client" section ).
实际上,通过使用MySQL代理(通过向下滚动到“来自MySQL客户端的Shell命令”部分),可以在mysqld通过客户端连接运行的服务器上执行shell命令(而不是在本地客户端计算机上执行命令)。
#4
0
As an additional tweak, on most "'nix" systems you can actually do something like this:
作为一个额外的调整,在大多数“'nix”系统上你可以实际做这样的事情:
mysql> system bash
And have the entire terminal at your disposal. This is particularly effective if you're doing code work in the terminal that interfaces with MySQL; from the shell, typing "exit" will take you back into the MySQL monitor/client, so you can go back and forth quite easily.
并为您提供整个终端。如果您在与MySQL接口的终端中进行代码工作,这将特别有效;从shell中输入“exit”会将你带回MySQL监视器/客户端,这样你就可以很容易地来回走动。
Obviously, other shells ("mysql> system tcsh") would work as well.
显然,其他shell(“mysql> system tcsh”)也可以正常工作。
#5
-1
In a linux machine you should be able to use the following example
在linux机器中,您应该能够使用以下示例
- ! clear - to clear the screen
- ! ls - to list files in the current working directory
- Basically you should be able to run any command or script using that syntax
!清除 - 清除屏幕
! ls - 列出当前工作目录中的文件
基本上,您应该能够使用该语法运行任何命令或脚本
NB: Add a back slash before !
注意:之前添加反斜杠!