How to send email using MySQL Server? [duplicate]

2019-09-20 00:25发布

问题:

This question already has an answer here:

  • How to send email from MySQL 5.1 4 answers

I am using MySQL server 5.0. I have a table named User_Login_Details. I want to receive email from my MySQL server when anyone tries to change anything in my Table. That may be Insert, Update or Delete.

How can I do this?

回答1:

As far as i know, i don't think MySQL server has no default SMTP setup or utilities packaged in. You will need to monitor the logs and generate mails yourself. If you are using it along with any other language such as PhP,Java,Python, C# then you can program an evented/polling model for this which will notify you in case of any change. Anyways you would have to monitor the logs. If binary logs are enabled, then you can write a script to notify changes.

If you do not want to monitor the logs, then you Could Monitor information_schema.tables. Loop through every table and check its UPDATE_TIME column in information_schema.tables

For more details check out these How to send email from MySQL 5.1 https://dba.stackexchange.com/questions/3159/mail-alert-from-mysql-when-databases-are-edited