Mysql scheduled script (event), similar to oracle job

Source: Internet
Author: User

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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.