What is MySQL event?

Source: Internet
Author: User
What is MySQL event?

MySQL event is the MySQL event scheduler and can be periodically executed. It is a bit like crontab in Linux, but MySQL event can be accurate to seconds. After using the event, you can partially replace the scheduled execution of crontab. However, you do not know if the event is stable or unstable.

1. Check whether MySQL event is enabled.

View copy print?
    1. Mysql> show variables like"Event %";
    2. + ----------------- + ------- +
    3. | Variable_name | value |
    4. + ----------------- + ------- +
    5. | Event_scheduler | off |
    6. + ----------------- + ------- +
    7. 1 row in Set

If not, set global event_schedld = 1; or add event_schedld = 1 to [mysqld] In my. CNF to save and restart MySQL.

II. A simple example

View copy print?
  1. Create Table: Create Table 'test '(// Test table
  2. 'Time' varchar (20) default null
  3. ) Engine = MyISAM default charset = Latin1
  4. 1 row in SET (0.00 Sec)
  5. // Create an event
  6. Mysql> Create event if not exists test_event on schedule every 5 secondDoInsert into test (time) values (now ());
  7. Query OK, 0 rows affected
  8. Mysql> select * from test;// View data
  9. + --------------------- +
  10. | Time |
  11. + --------------------- +
  12. | 09:14:52 |
  13. + --------------------- +
  14. | 09:14:57 |
  15. + --------------------- +
  16. 2 row in Set
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.