从 MySQL 触发器/存储过程执行 Shell 脚本/命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29820937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Execute Shell script/command from MySQL Trigger/Stored Procedure
提问by capacop
I'm currently writing my Main Assignment on my last semester at my study (IT-Engineering with Networking) and currently working with MySQL.
我目前正在我的研究(IT 工程与网络)的最后一个学期写我的主要作业,目前正在使用 MySQL。
My question is: Is it possible to execute a Shell script/Command from within a MySQL Trigger/Procedure? Or can it be done from a CASE statement? I've been searching around the internet and read that it's inadvisable to do it. But I need a script to check a table in a database for alerts and then warn people if there is any. If there is anyway else this could be done, then I'm open for ideas. Any input will be appreciated :)
我的问题是:是否可以从 MySQL 触发器/程序中执行 Shell 脚本/命令?或者可以从 CASE 语句中完成?我一直在互联网上搜索并读到这样做是不可取的。但是我需要一个脚本来检查数据库中的表是否有警报,然后在有警报时警告人们。如果还有其他方法可以做到,那么我愿意接受想法。任何输入将不胜感激:)
采纳答案by Pranab Sharma
You can read this blog for triggering a shell script from MySQL: https://patternbuffer.wordpress.com/2012/09/14/triggering-shell-script-from-mysql/
您可以阅读此博客以从 MySQL 触发 shell 脚本:https: //patternbuffer.wordpress.com/2012/09/14/triggering-shell-script-from-mysql/
I think for your requirement just write a python/php/perl script which will connect your MySQL DB and query the alert table for any alert and accordingly show warning message on the screen or send email/sms warning.
我认为根据您的要求,只需编写一个 python/php/perl 脚本,该脚本将连接您的 MySQL 数据库并查询警报表以获取任何警报,并相应地在屏幕上显示警告消息或发送电子邮件/短信警告。