MySQL定时执行脚本(计划任务)命令实例_MySQL
bitsCN.com
查看event是否开启
show variables like '%sche%';
将事件计划开启
set global event_scheduler =1;
创建存储过程test
CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 14;
END;
创建event e_test
create event if not exists e_test
on schedule every 30 second
on completion preserve
do call test();
每隔30秒将执行存储过程test,将当前时间更新到examinfo表中id=14的记录的endtime字段中去.
关闭事件任务
alter event e_test ON
COMPLETION PRESERVE DISABLE;
开户事件任务
alter event e_test ON
COMPLETION PRESERVE ENABLE;
以上测试均成功,测试环境为mysql 5.4.2-beta-community mysql community server(GPL)
以上的相关内容就是对MySQL定时执行的介绍,望你能有所收获。
mysql 计划任务重启后消失
我们只要修改一配置即可
event_scheduler在mysql的config中设置为OFF有关。去mysql中将配置改为ON则就搞定了。
更详细的大家可以往下看
MySQL5.1.x版本中引入了一项新特性EVENT,顾名思义就是事件、定时任务机制,在指定的时间单元内执行特定的任务,因此今后一些对数据定时性操作不再依赖外部程序,而直接使用数据库本身提供的功能。
要查看当前是否已开启事件调度器,可执行如下SQL:
SHOW VARIABLES LIKE 'event_scheduler';
或
SELECT @@event_scheduler;
或
SHOW PROCESSLIST;
若显示:
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | OFF |
+-----------------+-------+
则可执行
SET GLOBAL event_scheduler = 1;
或
SET GLOBAL event_scheduler = ON;
来开启,也可以直接在启动命令加上“

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Can't exit win11 preview program? When we use the win11 system, the win11 preview program will be launched on the computer for us to use. However, some friends do not want to use this preview program. I hope this preview program can be launched. If you don’t know how to exit, the editor below We have compiled a tutorial guide for exiting the Win11 preview experience program. If you are interested, let’s take a look below! Tutorial guide for exiting the Win11 Insider Program 1. First press the shortcut key "win+i" to enter Windows Settings and click "Update and Security". 2. Then click "Windows Insider Program" in the left taskbar, as shown in the figure. 3. At this point you can see the experience on the right

Zhongguancun News: On the morning of April 18, Huawei suddenly announced that the P70 series of mobile phones are officially on sale under the Pioneer Plan. Friends who want to buy should be prepared to take action. According to past practice, Huawei's flagship mobile phones are very popular and will always be out of stock. . This time the Huawei P70 series has been renamed Pura, which means pure. Previously, Huawei's Yu Chengdong said: Since 2012, Huawei's P series smartphones have been like loyal partners, accompanying hundreds of millions of users around the world to spend countless precious moments and jointly witness the beauty and excitement of life. He deeply felt that the trust and love given by every user who chooses Huawei's P series is tantamount to a powerful driving force, always inspiring Huawei to move forward firmly on the road of innovation. Pura means pure.

According to news on October 12, Russia has made important progress in the field of microelectronics. The Russian Ministry of Industry and Trade recently proposed a new microelectronics development roadmap aimed at improving the country's semiconductor technology level. It is understood that Russian microelectronics companies are currently able to produce chip products with a 130-nanometer process, and their new goal is to achieve large-scale production of 65-nanometer chips in 2026, followed by plans to manufacture 28-nanometer chips domestically in 2027, and in The move to achieve mass production of 14nm chips by 2030 has been highly praised by local experts, who believe that these technological advances will help Russia produce affordable laptops based on open source technologies such as Linux and RISC-V. Last year, the Russian government

According to news on December 3, Changan Automobile recently revealed the latest progress of its solid-state battery plan in its latest investor relations activity record. Changan Automobile is currently actively developing new electrolyte materials for semi-solid batteries and solid-state batteries, as well as key processes. According to our understanding, the company plans to gradually promote the development of solid-state batteries based on vehicle demand, and plans to gradually mass-produce applications from 2025. According to the editor's understanding, Changan Automobile is committed to improving the weight and energy density of batteries in the research and development of solid-state batteries. It is expected to reach 350-500 Wh/kg, and the volume energy density is also expected to reach 750-1000 Wh/L. It is expected that this new type of battery will be fully popularized by 2030. In addition, Changan Automobile is also developing lithium-sulfur batteries.

According to news on April 18, just now, Huawei officially launched the Pioneer Plan of Huawei Pura70 series. Huawei Pura70 Ultra is equipped with the industry's first super zoom periscope camera, allowing users to take incredible close and long-range photos without reducing image quality. This series also has an ultra-high-speed wind speed flash function, breaking the record for shooting speed. These new features allow photographers to get closer when shooting while maintaining high-quality images. The HUAWE IPura70 series is pre-installed with HarmonyOS4.2, providing a more interesting, smart and smooth flagship experience. The Beidou satellite messaging function has been upgraded to support sending picture messages to achieve more expressive communication. The series also supports AIAi

According to news on July 6, Apple China has recently made adjustments to its AppleTradeIn redemption plan, bringing good news to old users of Apple devices. According to the editor's understanding, in this plan, the trade-in deduction amount for iPhone, Mac, iPad and other devices has been increased. For iPhone products, the maximum discount amount for iPhone 13 Pro Max is 5,500 yuan, iPhone 13 Pro is 4,900 yuan, iPhone 13 is 3,350 yuan, iPhone 13 mini is 3,000 yuan, while the maximum discount amount for iPhone 12 Pro Max is 3,800 yuan, and the newly released iPhone SE No. The third generation

Recently, Google announced that it will terminate the Google Play Security Reward Program (GPSRP), which has been running for nearly 7 years, on August 31, 2024. This decision is based on the significant improvement in the security of the Android system. In an email to developers pointed out that as the security of the Android operating system has been enhanced and its functions have been hardened, the number of vulnerabilities available for security researchers to exploit has decreased, so the GPSRP program is no longer needed. 1. According to the plan, all vulnerability reports submitted before August 31 will be evaluated before September 15, and the final reward decision will be announced before the end of September. Google expressed its gratitude to the researchers who participated in the GPSRP and promised All submitted vulnerability reports will be reviewed and processed to ensure

Costudy is a software that focuses on time planning and mainly helps users better manage their daily time. If you want to better organize your daily time, Costudy is a very practical tool. Through Costudy, users can easily create task lists, set time reminders and arrange schedules to achieve efficient time management. So how do you make your own plans in Costudy? Players who want to know, please follow the article below. Let’s learn about the tutorials and strategies every month. How to make a plan in "costudy": 1. First, open costume and click "Diary" on the right. 2. Enter the diary page and click Add Today’s To-Do in the upper right corner. 3. Set today’s learning goals and click
