我可以使用 phpMyAdmin 设置 MySQL 事件时间表吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6622301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:25:49  来源:igfitidea点击:

Can I set a MySQL event schedule using phpMyAdmin?

mysqleventsphpmyadminmysql-event

提问by Lars

I want to increment a field on the first minute of every day, and then once it hits a certain value, set the value to 1. I would like to do this directly in MySQL, but preferably through phpMyAdmin.

我想在每天的第一分钟增加一个字段,然后一旦达到某个值,将值设置为 1。我想直接在 MySQL 中执行此操作,但最好通过 phpMyAdmin。

I am aware of the Event Scheduler, and so I'm looking for a way to use and manage it through phpMyAdmin. Is this possible?

我知道Event Scheduler,因此我正在寻找一种通过 phpMyAdmin 使用和管理它的方法。这可能吗?

回答by Mchl

It is.. Just issue appropriate CREATE EVENTSQL from SQL box.

它是.. 只需CREATE EVENT从 SQL 框中发出适当的SQL。

However: your MySQL server needs to have event scheduler enabled AND have EVENTprivileges for the database user.

但是:您的 MySQL 服务器需要启用事件调度程序并具有EVENT数据库用户的权限。

Calling SELECT @@event_scheduler;will tell you if the scheduler is available and enabled.

调用SELECT @@event_scheduler;将告诉您调度程序是否可用并已启用。

To enable event scheduler if it's disabled try calling SET GLOBAL event_scheduler := 1;You need the SUPERprivilege for this to succeed.

要在禁用事件调度程序时启用它,请尝试调用SET GLOBAL event_scheduler := 1;您需要此SUPER权限才能成功。

回答by Prabin Tp

Select query browser in phpmyadmin run the query to ON event scheduler

在 phpmyadmin 中选择查询浏览器运行查询到 ON 事件调度程序

SET GLOBAL event_scheduler = ON;

Only super privilege user can do this. To grand privilege to user by

只有超级特权用户才能做到这一点。对用户的大特权

GRANT EVENT ON myschema.* TO jon@ghidora;

Check event_sheduler status ON or OFF by

检查 event_sheduler 状态 ON 或 OFF

SELECT @@event_scheduler;

If status is ON go ahead for create event

如果状态为 ON 则继续创建事件

CREATE EVENT e_store_ts
    ON SCHEDULE
      EVERY 10 SECOND
    DO
      INSERT INTO myschema.mytable VALUES (UNIX_TIMESTAMP());

To see the events that created

查看创建的事件

SHOW EVENTS;

回答by Guy Chapman

If doing this on Amazon RDS you need to edit the parameter group to add EVENT_SCHEDULER = ON. One easy way to do this is via a free Rightscale account.

如果在 Amazon RDS 上执行此操作,您需要编辑参数组以添加EVENT_SCHEDULER = ON. 一种简单的方法是通过免费的 Rightscale 帐户。