MySQL 5.5 创建事件给出语法错误 [英] MySQL 5.5 Create event gives syntax error

查看:88
本文介绍了MySQL 5.5 创建事件给出语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建 EVENT 时遇到问题.

I have a problem creating EVENT.

我有一张articoli"表.有一个 articoli.titolo 字段 varchar (255),当我尝试创建这样的事件时:

I have an 'articoli' table. There is a articoli.titolo field varchar (255) and when I try to create the event like this:

CREATE EVENT inser_value
ON SCHEDULE every 1 day
DO INSERT INTO articoli (titolo) VALUES ('my_value');

这是mysqlerror的输出

This is the mysqlerror's output

ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册使用 near 'EVENT inser_value ON SCHEDULE 每 1 天的语法INSERT INTO articoli (titolo) VALUE' 在第 1 行

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use n ear 'EVENT inser_value ON SCHEDULE every 1 day DO INSERT INTO articoli (titolo) VALUE' at line 1

推荐答案

如果您的 MySQL 版本不支持 Event 模块,或者未启动,则会出现此错误.

This error appears if your MySQL version doesn't support the Event module, or if it's not started.

请检查这两个.

本文讲如何配置MySQL Event Scheduler.

启动 MySQL 的事件调度程序

MySQL 事件由一个特殊的事件调度程序线程执行.默认情况下它是禁用的,因此使用以下 MySQL 命令可以确定它是否正在运行:

MySQL events are executed by a special event scheduler thread. It’s disabled by default so use the following MySQL command can determine whether it’s running:

SHOW PROCESSLIST;  

如果调度程序正在运行,则至少会显示两行,其中一行将其用户字段设置为 event_scheduler.如果只返回一行,则调度程序被禁用,事件将不会运行.

If the scheduler is running, at least two rows will be shown and one will have its user field set to event_scheduler. If only one row is returned, the scheduler is disabled and events will not run.

您可以在 MySQL 配置文件中使用命令行选项 --event-scheduler=ONsetting event_scheduler=ON 确保启动 MySQL 时调度程序启动(Windows 上的 my.cnf 或 my.ini).

You can ensure the scheduler starts when MySQL is launched with the command-line option --event-scheduler=ON or setting event_scheduler=ON in your MySQL configuration file (my.cnf or my.ini on Windows).

或者,您可以从 MySQL 命令行启动调度程序:

Alternatively, you can start the scheduler from the MySQL command line:

SET GLOBAL event_scheduler = ON;  

这篇关于MySQL 5.5 创建事件给出语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆