How to get output of shell in MySQL?
In linux I can use ! to start a shell command:
mysql >\! ping localhost
Is there a way to get the output of shell in MySQL?开发者_如何学C
While in the mysql prompt, no. You can however pipe the results of a command into mysql with something similar to:
mysql -u user -ppassword < `ping localhost`
The only issue with this is that whatever your shell command returns needs to be the sum of the commands/data you want to issue to mysql. This is most commonly used to execute a script or something similar.
精彩评论