本文介绍了数据库迁移后Mysql事件未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级了服务器,此后,我调用例程的事件似乎无法正常工作.

I have recently upgraded my server and since then my event that calls a routine does not seem to be working correctly.

我知道该例程可以正常工作,因为我可以手动调用它,并且它没有显示任何错误.

I know that the routine works becuase I can call it manually and it shows no errors.

事件代码如下所示:

DROP EVENT `event_image_update_views`//
CREATE DEFINER=`root`@`localhost` EVENT `event_image_update_views` ON SCHEDULE EVERY 5 MINUTE STARTS '2013-06-05 11:00:00' ON COMPLETION NOT PRESERVE ENABLE DO CALL image_update_views()

基本上,它要求数据库在特定日期之后每5分钟调用一个名为image_update_views()的例程.

It basically asks the database to call a routine called image_update_views() every 5 minuets after a specific date.

我非常确定我数据库中的日期是正确的,但不是100%确定.我是否可以运行一个sql命令,该命令将返回当前时间/日期,以便可以肯定地知道我要提供将来的日期?

Im fairly sure the date on my database is correct but im not 100% sure. Is there a sql command that I can run that will return the current time/date, so that I know for certain that I am providing a future date?

我也不确定下面的行:

CREATE DEFINER=`root`@`localhost`

当然应该在这里使用root用户吗?

Surely the root user should be used here right?

phpmyadmin中是否有任何方法可以告知事件是否已运行?

Is there any way in phpmyadmin to tell if the event has run or not?

欢迎提出任何建议!

推荐答案

可能是您的MySQL事件计划程序未运行.

Could be that your the MySQL event scheduler is not running.

尝试以下操作以查看其是否正在运行:

Try this to see if it is running:

show variables like 'event_scheduler';

如果返回的值为OFF,则可能是原因.您可以通过运行以下命令将其重新打开:

If you get a value of OFF returned then this is probably the reason. You can switch it back on by running:

SET GLOBAL event_scheduler = ON;

如果您需要了解MySQL的当前日期和时间,可以运行:

If you need to know the MySQL current date and time you can run:

select now();

最后,您可以使用以下查询查看MySQL事件计划程序上次运行事件的时间:

Finally, you can see when an event was last run by the MySQL Event Scheduler using this query:

select event_schema,event_name,last_executed
from information_schema.events;

祝你好运!

编辑

如果默认需要打开event_scheduler,则转到my.cnf文件(如果使用Windows,则为my.ini文件),然后注释event_scheduler=DISABLED或设置event_scheduler=ON.然后重新启动您的MySQL服务器.

If you need to switch your event_scheduler on by default then head over to your my.cnf file (or my.ini file if you are using Windows) and either comment out event_scheduler=DISABLED or set event_scheduler=ON. Then restart your MySQL server.

有关它的更多信息此处 .

There is some more info about it here.

这篇关于数据库迁移后Mysql事件未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 16:00