From 161841925da5048228aa3c3147a8bfaec078d7b0 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 6 Mar 2025 20:35:35 +0000 Subject: [PATCH] Force the MySQL module to use UTC for connections. This prevents conversion issues when the MySQL server is in a different timezone to the services server. --- modules/extra/mysql.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index 1f6777bcc..294ddfac0 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -631,6 +631,10 @@ void MySQLService::Connect() if (!connect) throw SQL::Exception("Unable to connect to MySQL service " + this->name + ": " + mysql_error(this->sql)); + // We force UTC so that FromUnixtime works as expected. + SQL::Query tzquery("SET time_zone = '+00:00'"); + RunQuery(tzquery); + if (this->socket.empty()) Log(LOG_DEBUG) << "Successfully connected to MySQL service " << this->name << " at " << this->server << ":" << this->port; else