一次意外的发现创建完Event之后,information_schema.events和mysql.event表中execute_at和last_executed字段均相差8个小时,mysqld实例的时区为:
测试过程
创建测试数据库
创建测试数据表
创建Event
执行SQL语句查询mysqld实例的时区和时间
执行SQL语句查询information_schema.events表和mysql.event表中execute_at和last_executed字段值
问题原因
为了确保Event的执行不受时区的影响,使得Event可以准确执行,MySQL将mysql.event表的事件调度时间(execute_at和last_executed)转换成UTC时间。
文档描述:
Times in the ON SCHEDULE clause are interpreted using the current session time_zone value. This becomes the event time zone; that is, the time zone that is used for event scheduling and is in effect within the event as it executes. These times are converted to UTC and stored along with the event time zone in the mysql.event table. This enables event execution to proceed as defined regardless of any subsequent changes to the server time zone or daylight saving time effects.
Copyright © 广州京杭网络科技有限公司 2005-2024 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有