一次意外的發現創建完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.