1.开启事件
修改 my.cnf
[mysqld] event_scheduler=ON group_concat_max_len=1024000 character_set_server=utf8 general_log=ON general_log_file=/etc/mysql/log/general.log log_error=/etc/mysql/log/error.log
或者
set global event_scheduler=ON
2.创建事件
delimiter $$ CREATE EVENT FLUSH_TEST ON SCHEDULE EVERY 1 DAY STARTS TIMESTAMP '2018-02-25 00:00:00' DO BEGIN INSERT INTO clarify_issue(statistics_time,project,issuekey,summary,`owner_job_id`,`owner`,duedate,reopentime_or_overduedays) SELECT report_time,project_name,jira_id,summary,resolver,resolver_displayName,duedate,reopen_time AS 'reopentime_or_overduedays' FROM work_huaqin.daily_reopen_Bug WHERE report_time=CURRENT_DATE() UNION ALL SELECT report_time,project_name,jira_id,summary,resolver,resolver_displayName,duedate,reopen_time AS 'reopentime_or_overduedays' FROM work_huaqin.daily_reopen_Task WHERE report_time=CURRENT_DATE() UNION ALL SELECT report_time,project_name,jira_id,summary,resolver,resolver_displayName,duedate,reopen_time AS 'reopentime_or_overduedays' FROM tb_liverpool.daily_reopen WHERE report_time=CURRENT_DATE() UNION ALL SELECT report_time,project_name,jira_id,summary,resolver,resolver_displayName,duedate,reopen_time AS 'reopentime_or_overduedays' FROM rainbow.daily_reopen WHERE report_time=CURRENT_DATE() UNION ALL SELECT report_time,project_name,jira_id,summary,resolver,resolver_displayName,duedate,reopen_time AS 'reopentime_or_overduedays' FROM basin.daily_reopen WHERE report_time=CURRENT_DATE(); END $$