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?
相关问题
- How to get the return code of a shell script in lu
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
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.
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.
You can use the
system
command.Example:
As an additional tweak, on most "'nix" systems you can actually do something like this:
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.
Obviously, other shells ("mysql> system tcsh") would work as well.
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 ).
In a linux machine you should be able to use the following example
NB: Add a back slash before !