Mysql scheduled script (event), similar to oracle job, I have two tables: tb_push_data and snapshot now need to back up the Qualified Data of tb_push_data to the table tb_push_data_log www.2cto.com every once in a while. Create a stored procedure delimiter $ USE 'push _ server_db '$ DROP PROCEDURE IF EXISTS 'proc _ tb_push_data_backup '$ create definer = 'root' @ 'localhost' PROCEDURE 'proc _ tb_push_data_backup '() begin start transaction; insert into tb_push_data_log (id, created_date, data_id, gps, have_image, message, recv_name,
Recv_username, send_name, send_username, STATUS, tool, updated_date, uri, image_path, log_time) SELECT id, created_date, data_id, gps, have_image, message, recv_name, recv_username, send_name,
Send_username, STATUS, tool, updated_date, uri, image_path, NOW () FROM tb_push_data where status = 'already _ RECEIVE '; delete from tb_push_data where status = 'already _ RECEIVE'; COMMIT; END $ DELIMITER; 2. CREATE a MYSQL event DELIMITER $ CREATE event event_tb_push_data_backup on schedule every 5 minute starts now () do begin call event_tb_push_data_backup (); END; DELIMITER; 3. Verify and modify whether the event www.2cto.com has been enabled for the database. After you have completed the event following the example, you may find that the event has not been run, most of the reasons are that the event_scheduler status is not enabled. Check the event_scheduler status show variables like '% sche %'. Modify the event_scheduler status set global event_scheduler = 1;