I wanted to know if MySQL let the admin set a timezone per database ?

I have three different databases for three different customers. Each of them being in their own timezone.

I would like to load the exact same event for each customer and would like it to run everyday at 00:00:01 for their respective timezone. Is it possible ?

I can load three different sql script specifying in each their respective timezone, but it doesn't scale well and it make me have three version of almost the same file.



MySQL time zone support includes only a global default time zone and a per-connection time zone. Since any given connection can dynamically USE (as default) any database for which it has privileges, or no database at all, and tables within a single query can cross databases, the concept of a per-database timezone wouldn't be particularly meaningful, much less unambiguous.


However, if your setup script sets the time zone in its session before defining the scheduled event, that time zone will be used by the scheduler to transform the time you requested the scheduled event into 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.