Home > Database > Mysql Tutorial > mysql创建作业及问题解决_MySQL

mysql创建作业及问题解决_MySQL

WBOY
Release: 2016-06-01 13:47:07
Original
918 people have browsed it

bitsCN.com

1.创建存储过程。
2.创建事件(定时执行存储过程)。
举例,如有表STUDENT 字段有id、name、age、login_time(登录时间);
每30秒更新登录时间为当前时间。
(1)创建STUDENT表。
(2)创建存储过程pro_student:
begin
update STUDENT set login_time=now();
end
保存
(3)创建事件e_student
CREATE EVENT if not exists e_student
          on schedule every 30 second
          on completion preserve
     do call pro_student();
3.如果没有生效则查看event和事件任务是否开启:
查看event是否开启: show variables like %sche%;
将事件计划开启: set global event_scheduler=1;
关闭事件任务: alter event e_test ON COMPLETION PRESERVE DISABLE;
开户事件任务: alter event e_test ON COMPLETION PRESERVE ENABLE;

在创建作业时报以下错误,
在打开数据库时客户端提示“Cannot proceed because system tables used by Event Scheduler were found damaged at server start”
造成此原因是MySQL服务器的当前版本不兼容所有数据库的表
解决方法
1、linux、windows下解决方法类似
$PATH /mysql_upgrade -u root -p
例如:/usr/local/mysql/bin/mysql_upgrade - u root -p     [回车输入密码即可]
$PATH mysql安装路径  我这里是用的(D:wampinmysqlmysql5.1.30in)
执行完后停止mysqld后再重新启动mysqld一次,问题即可解决。

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template