Analysis and solution of the reasons why MySQL scheduled tasks cannot be executed normally

Analysis and solution of the reasons why MySQL scheduled tasks cannot be executed normally

Preface

When using database scheduled tasks, the scheduled tasks often fail to execute. This article analyzes and summarizes the causes and solutions to this problem.

Cause analysis and solutions

When we find that the MySQL scheduled task is not executed, first check whether the [Last Run] time in the scheduled task is correct to determine whether it is executed normally. If it is executed normally, you need to consider whether the event logic is incorrect.

View the last run time

If the last run time is empty or incorrect, you need to check whether the database has a scheduled task enabled. You can query by executing the following query statement:

show VARIABLES like '%event_schedule%'

If the result is ON, it means that the database has enabled the scheduled task, and if it is OFF, it has not.

Correct result

If the query result is OFF, there are two solutions:

1. Set directly in the database

SET GLOBAL event_scheduler = ON;

This method takes effect immediately, but will become invalid after the database is restarted .

2. Make changes in the database configuration file

Add the following code to the [mysqld] module in my.ini:
event_scheduler=ON
This method requires the database to be restarted to take effect and will not become invalid when the database is restarted .

After starting the scheduled task of the database, you also need to check whether your own scheduled task is executable. Execute the following query statement in the database:
show events
Check whether the Status in the query result is correct. If the result is ENABLE , it means it has been started.

Status needs to be ENABLE

If the status is not ENABLE, we need to change it to ENABLE in the status bar of the scheduled task.

Change the scheduled task status to ENABLE

Make scheduled tasks execute quickly

Some scheduled tasks are executed once a day or longer. If you want time to flow naturally to test it will be troublesome. At this time, we need to modify the time of the database server according to the plan, so that we can quickly test whether the scheduled task can be executed normally.

Summarize

This concludes this article on the reasons why MySQL scheduled tasks cannot be executed normally and the solutions. For more relevant MySQL scheduled tasks, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to configure MySQL scheduled tasks (EVENT events) in detail
  • MySQL scheduled task implementation and usage examples
  • Analysis of the method of setting up scheduled tasks in mysql
  • Detailed explanation of mysql scheduled tasks (event events)
  • How to implement Mysql scheduled task backup data under Linux
  • MySQL scheduled task example tutorial
  • How to implement Mysql scheduled tasks under Linux

<<:  Front-end AI cutting tips (experience)

>>:  WeChat applet custom menu navigation to achieve staircase effect

Recommend

Docker network mode and configuration method

1. Docker Network Mode When docker run creates a ...

Methods and techniques for designing an interesting website (picture)

Have you ever encountered a situation where we hav...

Summary of Docker configuration container location and tips

Tips for using Docker 1. Clean up all stopped doc...

Guide to using env in vue cli

Table of contents Preface Introduction-Official E...

Introduction to new features of MySQL 8.0.11

MySQL 8.0 for Windows v8.0.11 official free versi...

A brief discussion on the fun of :focus-within in CSS

I believe some people have seen this picture of c...

JavaScript exquisite snake implementation process

Table of contents 1. Create HTML structure 2. Cre...

Do you know all 24 methods of JavaScript loop traversal?

Table of contents Preface 1. Array traversal meth...

How to configure VMware multi-node environment

This tutorial uses CentOS 7 64-bit. Allocate 2GB ...

A brief discussion on the whole process of Vue's first rendering

Table of contents 1. Vue initialization vue entry...

One question to understand multiple parameters of sort command in Linux

The sort command is very commonly used, but it al...

Full process record of Nginx reverse proxy configuration

1. Preparation Install Tomcat on Linux system, us...

Key features of InnoDB - insert cache, write twice, adaptive hash index details

The key features of the InnoDB storage engine inc...