Mysql job creation and troubleshooting

Source: Internet
Author: User

1. Create a stored procedure.
2. Create an event (scheduled execution of the stored procedure ).
For example, if the STUDENT field of a table contains id, name, age, and login_time (logon time );
The logon time is updated to the current time every 30 seconds.
(1) create a STUDENT table.
(2) create a stored procedure pro_student:
Begin
Update STUDENT set login_time = now ();
End
Save
(3) create event e_student
Create event if not exists e_student
On schedule every 30 second
On completion preserve
Do call pro_student ();
3. If it does not take effect, check whether the event and event task are enabled:
Check whether the event is Enabled: show variables like % sche %;
Enable the event plan: set global event_scheduler = 1;
Close event task: alter event e_test on completion preserve disable;
Account Opening event task: alter event e_test on completion preserve enable;

The following error is reported when you create a job,
When you open the database, the client prompts "Cannot proceed because system tables used by Event sched1_were found damaged at server start"
This is because the current MySQL Server version is not compatible with all database tables.
Solution
1. The solution for linux and windows is similar.
$ PATH/mysql_upgrade-u root-p
For example:/usr/local/mysql/bin/mysql_upgrade-u root-p [Press enter to enter the password]
$ PATH mysql installation path I use here (D: wampinmysqlmysql5.1.30in)
After the execution, stop mysqld and restart mysqld once. The problem can be solved.

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.