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);
show variables like '%event_sche%';
set global event_scheduler=1;
1
show variables like '%event_sche%';
1
set global event_scheduler=1;
12
[mysqld]event_scheduler=on //這一行加入mysqld標籤下
1234567
use test;delimiter //
create procedure test_proce()
begin
insert into weuse(name,created_at,updated_at) values('hello',now(),now());
end//
delimiter ;
enter image description here
上面建立儲存過程實際上是為定時任務做鋪墊的,因為上面只說明了怎麼建立儲存過程,但是未說明怎麼呼叫,那這裡就用到了呼叫儲存過程了。
1234
create event second_eventon schedule every 1 second
on completion preserve disable
do call test_proce();
enter image description here
1
select event_name,event_definition,interval_value,interval_field,status from information_schema.events;
enter image description here
12
alter event second_event on completion preserve enable;//開啟定時任務alter event second_event on completion preserve disable;//關閉定時任務
enter image description here
是官方推薦的免費視覺化mysql操作工具,方便建模,er圖操作,經我發現好像只能視覺化操作儲存過程(也可能是自己沒找到)enter image description here
12
select * from information_schema.events;//檢視所有事件屬性select event_name,event_definition,interval_value,interval_field,status from information_schema.events;//檢視主要幾個屬性
enter image description here
這個是收費的軟體,但是視覺化操作比較輕量級,功能也很多,它可以視覺化操作儲存過程和event事件,詳細操作大家可以自己摸索啊!!
Mysql 建立定時任務
1 首先連線 mysql 命令 mysql uroot p123456 自己總結 檢視事件 show events select from mysql.event 檢視是否開啟定時器 show variables like event scheduler 建立定時任務 create event e ...
mysql建立定時任務
1.檢視event是否開啟 show variables like sche 2.將事件計畫開啟 set global event scheduler 1 或 set global event scheduler on 3.例子 一.12點整執行accountall 函式 create event ...
mysql建立定時任務
1.啟動事件排程器 a.設定mysql全域性變數 set global event scheduler 1 b.修改配置檔案加入 event scheduler 1 event scheduler 1 檢視事件排程器是否啟動 show variables like event scheduler 2...