Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL 5.5How to create and view database scheduled tasks

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to create and view database planning tasks in MySQL 5.5. the editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

-- View relevant parameters

Mysql > show variables like'% event%'

+-+ +

| | Variable_name | Value |

+-+ +

| | event_scheduler | OFF |

| | performance_schema_events_waits_history_long_size | 10000 | |

| | performance_schema_events_waits_history_size | 10 | |

+-+ +

3 rows in set (0.00 sec)

-- enable relevant parameters

Mysql > set global event_scheduler = 1

Query OK, 0 rows affected (0.00 sec)

Mysql > show variables like'% event%'

+-+ +

| | Variable_name | Value |

+-+ +

| | event_scheduler | ON |

| | performance_schema_events_waits_history_long_size | 10000 | |

| | performance_schema_events_waits_history_size | 10 | |

+-+ +

3 rows in set (0.00 sec)

-- when the parameter is enabled, event_scheduler-related threads will appear in the thread

Mysql > show processlist\ G

* 7. Row * *

Id: 13

User: event_scheduler

Host: localhost

Db: NULL

Command: Daemon

Time: 474

State: Waiting for next activation

Info: NULL

7 rows in set (0.00 sec)

-- create scheduled tasks

Mysql > CREATE EVENT myevent

-> ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR

-> DO

-> UPDATE fire.t12 SET sal = sal + 100

Query OK, 0 rows affected (0.02 sec)

-- check the scheduled tasks in the database

Mysql > show events from fire\ G

* * 1. Row *

Db: fire

Name: myevent

Definer: system@localhost

Time zone: SYSTEM

Type: ONE TIME

Execute at: 2016-05-23 02:48:03

Interval value: NULL

Interval field: NULL

Starts: NULL

Ends: NULL

Status: ENABLED

Originator: 100

Character_set_client: gbk

Collation_connection: gbk_chinese_ci

Database Collation: utf8_general_ci

1 row in set (0.00 sec)

-- View the contents of the scheduled task

Mysql > show create event myevent\ G

* * 1. Row *

Event: myevent

Sql_mode: STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION

Time_zone: SYSTEM

Create Event: CREATE DEFINER= `system` @ `localhost` EVENT `myevent` ON SCHEDULE AT '2016-05-23 02 purge 48 purl 03' ON COMPLETION NOT PRESERVE ENABLE DO UPDATE fire.t12 SET sal = sal + 100

Character_set_client: gbk

Collation_connection: gbk_chinese_ci

Database Collation: utf8_general_ci

1 row in set (0.00 sec)

-- prohibition of scheduling tasks

Mysql > ALTER EVENT myevent DISABLE

This is the end of this article on "how to create and view database planning tasks for MySQL 5.5". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report