1.檢視event是否開啟
show variables like '%sche%';
2.將事件計畫開啟
set global event_scheduler =1;或
set global event_scheduler = on;
3.例子
一.12點整執行accountall()函式:
create event test
on schedule at timestamp '2019-07-02 10:10:00'
do call accountall(now());
二.5天後清空test表
create event e_test
on schedule at current_timestamp + interval 5 day
do truncatetable test.aaa;
三.每天定時清空test表
create event e_test
on schedule every 1 day
do truncatetable test.aaa;
四.每天定時清空test表,5天後停止執行
create event e_test
ons chedule every 1 day
ends current_timestamp+ interval 5 day
do truncatetable test.aaa;
五. 5天後開啟每天定時清空test表
create event e_test
on schedule every 1 day
starts current_timestamp+ interval 5 day
do truncatetable test.aaa;
六。每小時執行一次,12點開始準點執行
create event stars
on schedule every 1 hour
starts '2019-07-03 12:00:00'
do call star_ranks();
4.、刪除事件
drop event e_test;
Mysql 建立定時任務
1 首先連線 mysql 命令 mysql uroot p123456 自己總結 檢視事件 show events select from mysql.event 檢視是否開啟定時器 show variables like event scheduler 建立定時任務 create event e ...
mysql建立定時任務
1.啟動事件排程器 a.設定mysql全域性變數 set global event scheduler 1 b.修改配置檔案加入 event scheduler 1 event scheduler 1 檢視事件排程器是否啟動 show variables like event scheduler 2...
mysql建立定時任務
use mis create table mis.aaa timeline timestamp create event e test insert on schedule every 1 second 1秒觸發一次 do insert mis.aaa value current timestamp...