简体   繁体   English

如何将MySQL报告发送到电子邮件

[英]How to send MySQL reports to an e-mail

I have PHP server with MySQL installed on it. 我有安装MySQL的PHP​​服务器。

I wrote few Queries that I would like to get to my email every day on a specific hours. 我写了一些查询,希望每天在特定的时间收到我的电子邮件。

I'm looking for a simple solution to run those queries every day and send them to an email address. 我正在寻找一种简单的解决方案来每天运行这些查询并将其发送到电子邮件地址。

If possible to get the reports attached in csv it will be awesome. 如果有可能将报告附加到csv中,那将很棒。

When I worked with microsoft they had SSRS (Sql server reporting services). 当我与Microsoft合作时,他们拥有SSRS(Sql服务器报告服务)。

I would put something like this in my crontab: 我会在crontab中放入以下内容:

20 09 * * * mysql --user=you --password=secret -e 'show databases;' | mailx -s "SQL Results" you@somewhere.com

to run the "show databases" query every day at 09:20am and mail you the results. 每天上午09:20运行“显示数据库”查询,并将结果邮寄给您。 (Yes, I know there are issues with the password being visible, but I am showing the principle, not treatising on security.) (是的,我知道密码可见是有问题的,但是我是在说明原理,而不是在安全性方面作论述。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM