Home  >  Article  >  Database  >  Mysql checks whether the event is executed

Mysql checks whether the event is executed

anonymity
anonymityOriginal
2019-05-08 17:24:275705browse

What are MySQL events?

Mysql5.1 version began to introduce the event concept. Event is a "time trigger", which is different from the event triggering of triggers. Event is similar to the Linux crontab scheduled task and is used for time triggering. By using it alone or by calling a stored procedure, the relevant SQL statement or stored procedure is triggered at a specific point in time.

Mysql checks whether the event is executed

#How to operate MySQL events?

Check whether the event is enabled:

select @@event_scheduler;

show variables like 'event_scheduler';

show events; show full events ;show create event event_name;

show processlist;

The following EVENT commands are available:
(1) Query the mysql.event table;
(2) Through the SHOW EVENTS command;
(3) Through the SHOW FULL EVENTS command;
(4) By querying the information_schema.events table
(5) SHOW CREATE EVENT.
In short, if the frequency of event usage is low, it is recommended to use the root user for creation and maintenance.

Query the information_schema.events table

select * from information_schema.events limit 1\g;

Open mysql events:

set global event_scheduler = on ;The parameters take effect immediately

Change the configuration file and restart event_scheduler=on

Add the [mysqld] section in my.cnf, and then restart mysql.

Start by specifying event parameters

mysqld... --event_scheduler=on

Usage suggestions

1) Main library Already executed, the slave database ensures that the event will not be executed (unless the event is intentionally created on the slave)

2) Creation, deletion and other operations are strictly prohibited from directly operating the mysql.event table, but through create and other formal Syntax implementation

3) If the created event involves massive data changes, sufficient testing must be done to ensure that it does not affect the existing network service

4) If you need to back up the DB with the event, mysqldump You need to add the --event parameter

The above is the detailed content of Mysql checks whether the event is executed. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn