May I know how do we configure the time zone in Testcontainers MySQL during testing? Also, how can we verify the time zone in Testcontainers MySQL?
May I know how do we configure the time zone in Testcontainers MySQL during testing? Also, how can we verify the time zone in Testcontainers MySQL?
You may use the jdbc connection string to make the MySQL testcontainer use your "cnf" file, which sets the timezone
jdbc:tc:mysql:5.7.34://hostname/databasename?TC_MY_CNF=mysql_conf_override
And under mysql_conf_override folder you need to have a my.cnf file with the following content:
[mysqld]
default-time-zone = "Europe/Istanbul"
Finally, you may check the TZ in your testcontainer via
SELECT @@GLOBAL.time_zone, @@SESSION.time_zone;
after connecting to the container:
mysql -u root -ptest